Simon
Simon

Reputation: 25993

If I kill a delete query in mysql, will the rows all be saved?

Suppose I'm halfway through running an import, and instead of running

SELECT COUNT(*) FROM table_being_imported

I hit ctrl+R, type table_being_im and hit return, only to find to my horror that I've just issued

DELETE FROM table_being_imported

Oops. So I hit ctrl+C and get told:

Ctrl-C -- sending "KILL QUERY 627" to server ...
Ctrl-C -- query aborted.
ERROR 1317 (70100): Query execution was interrupted

Would it have deleted any of the rows? Just hypothetically, of course...

Upvotes: 5

Views: 2736

Answers (1)

FatherStorm
FatherStorm

Reputation: 7183

hypothetically,... some of those rows are now gone.

During UPDATE or DELETE operations, the kill flag is checked after each block read and after each updated or deleted row. If the kill flag is set, the statement is aborted. Note that if you are not using transactions, the changes are not rolled back.

Not that this is the time to mention it, but this is why Transactional queries are best when dealing with business-critical data.

Upvotes: 10

Related Questions