0

Can we undo more than one change in mysql? I deleted some rows and did a select * to see the table. I saw ROLLBACK but I guess it only reverts the action by last query. Can I undo deleting those rows?

If there is no way to undo more than one changes, is there a way to view last edited table and undo change done before viewing it? Also, are changes before last query committed(even when AUTOCOMMIT is 0)?

SS306
  • 157
  • 1
  • 3
  • 9

2 Answers2

0

From the reference manual: http://dev.mysql.com/doc/refman/5.1/en/commit.html

By default, MySQL runs with autocommit mode enabled. This means that as soon as you execute a statement that updates (modifies) a table, MySQL stores the update on disk to make it permanent.

This means that after you have deleted your records (and committed explicitly or implicitly), you cannot roll them back.

Rollback is a kind of undo for things which change data in tables, however in order to use you have to either:

  • turn off auto commit and use commit statements explicitly.
  • make your changes in transactions
  • there are statements which cause implicit commits: link
Michał Szkudlarek
  • 1,443
  • 1
  • 21
  • 35
0

the solution for the issue is that please heck that you binary logs has been activated in your server, if you have binary logs active on your server you can use mysqlbinlog

After taht generate a sql file with it

mysqlbinlog binary_log_file > query_log.sql

then find your missing rows.If not you have to keep Backup your DB from next time

Venkatvasan
  • 491
  • 3
  • 13