Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.
+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | MP        |  4500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
+----+----------+-----+-----------+----------+ 

Query :

UPDATE CUSTOMERS SET ADDRESS = 'Pune' WHERE ID = 6;

After successfully executing this query How do i back in previous stage in MySQL

i have tried rollback but it is not working

Engine InnoDB

Please Help

share|improve this question
1  
What's your storage engine (InnoDB, MyISAM, etc.)? –  Mat Sep 23 '13 at 13:32
add comment

1 Answer

up vote 1 down vote accepted

If your table engine is not InnoDB, or you haven't used transactions for this operation, then it might be not possible.

To have possibility to ROLLBACK DML statements (like INSERT, UPDATE or DELETE queries) you should use transaction blocks:

START TRANSACTION;

UPDATE CUSTOMERS SET ADDRESS = 'Pune' WHERE ID = 6;
-- and more DML queries

COMMIT; -- or ROLLBACK;

Since transaction was COMMITed it can not be rolled back. Only option (that I see) is to restore database backup (if it exists).


UPDv1:

Just as an advice: Before you do any critical changes to database (perform transactions, execute complex scripts, that includes INSERTs, UPDATEs and DELETEs or change data structures with ALTERs or DROPs) make a backup of your database.

You may probably restore backup as another database copy, then test script on it. If nothing goes wrong, then perform script for a real database.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.