Is there a way we can undo a SQL update query?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t unless you ran it inside a transaction.
Depending on your DBMS transactions will be handled differently, so read the documentation. For instance with mysql here’s how it goes:
With Postresql:
With TSQL:
There are also some actions that can’t be put into a transaction, but in most of the database management systems you can find these days you should be able to rollback an
update.Finally you can always undo an update if you keep a precise log of everything that happens in the database, but that’s another story.