How can I undo the most recently executed mysql query?
+7
A:
Basically: If you're doing a transaction just do a rollback. Otherwise, you can't "undo" a MySQL query.
halfdan
2010-05-27 06:07:10
MySQL doc about transactions: http://dev.mysql.com/doc/refman/5.0/en/commit.html
Unkwntech
2010-05-27 06:08:17
Let's hope you have logs and backups...
Konerak
2010-05-27 07:26:01
+1
A:
You can only do so during a transaction.
BEGIN;
INSERT INTO xxx ...;
DELETE FROM ...;
Then you can either:
COMMIT; -- will confitm your changes
Or
ROLLBACK -- will undo
Palantir
2010-05-27 06:08:21
+1
A:
If you define table type as InnoDB, you can use transactions (see the link below). You will need set AUTOCOMMIT=0, and after you can issue COMMIT or ROLLBACK at the end of query or session to submit or cancel a transaction.
http://dev.mysql.com/doc/mysql/en/InnoDB_transaction_model.html
ROLLBACK -- will undo the changes that you have made
Vimard
2010-05-27 06:10:16
+1
A:
You can stop a query which is being processed by this
Find the Id of the query process by => show processlist;
Then => kill id;
RINSON KE
2010-05-27 06:32:37