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...
The standard DELETE statement in SQL returns the number of deleted rows.
Once the row is deleted it is gone. You can will have to use a backup to restore the data. The exceptions to this are if you are doing a delete inside an open Transaction, in those cases you can "Rollback" the transaction to undo any changes made inside the transaction.
If you run a DELETE statement with no conditions in the WHERE clause, all of the records from the table will be deleted.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With