Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I undo a mysql statement that I just executed?

Tags:

mysql

rollback

How can I undo the most recently executed mysql query?

like image 260
Hari kanna Avatar asked May 27 '10 06:05

Hari kanna


People also ask

Is there an undo command in MySQL?

Can we rollback after commit in MySQL. No. Unfortunately you cannot undo changes that have been committed to the database.

How do I rollback a MySQL query?

The COMMIT statement saves all the modifications made in the current. The ROLLBACK operation undoes all the changes done by the current transaction i.e. If you invoke this statement, all the modifications are reverted until the last commit or the START TRANSACTION statement.

How do I undo a SQL statement?

You can undo changes that aren't committed to source control yet. In the Object Explorer, right-click the object, folder, or database with changes you want to undo, select Other SQL Source Control tasks > Undo changes. Alternatively, right-click an object on the Commit tab, and click Undo changes.

How do I abort a MySQL query?

Run the following command: mysql> SELECT GROUP_CONCAT(CONCAT('KILL ',id,';') SEPARATOR ' ') FROM information_schema. processlist WHERE user <> 'system user'; This will kill all your MySQL queries.


1 Answers

If you define table type as InnoDB, you can use transactions. 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.

ROLLBACK -- will undo the changes that you have made 
like image 140
Vimard Avatar answered Sep 20 '22 04:09

Vimard