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

后端 未结 10 2026
臣服心动
臣服心动 2020-12-25 09:32

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

相关标签:
10条回答
  • 2020-12-25 10:15

    Use the BEGIN TRANSACTION command before starting queries. So that you can ROLLBACK things at any point of time.

    FOR EXAMPLE:

    1. begin transaction
    2. select * from Student
    3. delete from Student where Id=2
    4. select * from Student
    5. rollback
    6. select * from Student
    0 讨论(0)
  • 2020-12-25 10:15

    If you want rollback data, firstly you need to execute autocommit =0 and then execute query delete, insert, or update.

    After executing the query then execute rollback...

    0 讨论(0)
  • 2020-12-25 10:16

    If you didn't commit the transaction yet, try rollback. If you have already committed the transaction (by commit or by exiting the command line client), you must restore the data from your last backup.

    0 讨论(0)
  • 2020-12-25 10:16

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

    0 讨论(0)
  • 2020-12-25 10:19

    Rollback normally won't work on these delete functions and surely a backup only can save you.

    If there is no backup then there is no way to restore it as delete queries ran on PuTTY,Derby using .sql files are auto committed once you fire the delete query.

    0 讨论(0)
  • 2020-12-25 10:27

    I also had deleted some values from my development database, but I had the same copy in QA database, so I did a generate script and selected option "type of data to script" to "data only" and selected my table.

    Then I got the insert statements with same data, and then I run the script on my development database.

    0 讨论(0)
提交回复
热议问题