the_iceman
the_iceman

Reputation: 45

Mysql workbench rollback not returning the table to last commit?

I'm using the rollback command to go to the previous commit but it doesn't seem to work.

I have tried executing the query multiple time and making sure that I didn't commit again but it doesn't work. I have copied the db from another table. I've executed the command as a block and as a whole but the result remains the same.


INSERT INTO departments_dup
select * from departments;

COMMIT;

UPDATE departments_dup
SET
    dept_no = 'd011',
    dept_name = 'Quality Control';

select * from departments_dup;

ROLLBACK;

The table should get back to its previous state but it doesn't seem to be working.

Upvotes: 1

Views: 1916

Answers (2)

user2958137
user2958137

Reputation: 101

If your database tables were created using MyISAM, you will need to backup your database, do a find and replace 'MyISAM' to 'InnoDB' in your backup file and then restore your database.

Upvotes: 0

Rahat
Rahat

Reputation: 90

Simply use auto-commit before executing ROLLBACK or COMMIT. It worked perfectly for me.

set autocommit = 0;

INSERT INTO departments_dup
select * from departments;

COMMIT;

UPDATE departments_dup
SET
dept_no = 'd011',
dept_name = 'Quality Control';

select * from departments_dup;

ROLLBACK;

Upvotes: 2

Related Questions