Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I roll back my last delete command in MySQL?

I accidentally deleted some huge number of rows from a table...

How can I roll it back?

I executed the query using PuTTY.

I'll be grateful if any of you can guide me safely out of this...

like image 984
Vijay Avatar asked Mar 01 '10 14:03

Vijay


People also ask

Can delete be rolled back in MySQL?

If you are performing the DELETE within a TRANSACTION , the action can always be rolled-back until you COMMIT it.

How do I rollback a delete in SQL?

Following is an example, which would delete those records from the table which have the age = 25 and then ROLLBACK the changes in the database. SQL> DELETE FROM CUSTOMERS WHERE AGE = 25; SQL> ROLLBACK; Thus, the delete operation would not impact the table and the SELECT statement would produce the following result.

How do I roll back a command in MySQL?

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.

Can we rollback delete command?

The operation cannot be rolled back. DROP and TRUNCATE are DDL commands, whereas DELETE is a DML command. DELETE operations can be rolled back (undone), while DROP and TRUNCATE operations cannot be rolled back.


1 Answers

If you haven't made a backup, you are pretty much fudged.

like image 157
Omry Yadan Avatar answered Sep 22 '22 14:09

Omry Yadan