Rolling back a transaction¶
Rolling back a transaction discards every change you have made since the transaction started, returning the database to exactly the state it was in before. Roll back when something has gone wrong, or when you were only testing and don't want to keep the results.
To roll back the active transaction:
- Select the database in the tree panel.
- Choose Transaction → Rollback from the main menu.
All provisional changes are undone and the database returns to autocommit mode.
You can also roll back from a script with the ROLLBACK command:
BEGIN TRANSACTION;
DELETE FROM orders WHERE CustNo = 1231; -- remove this customer's orders...
ROLLBACK; -- ...then change our mind and undo it
After the ROLLBACK, the orders rows are still there, untouched.
Tip
A rollback is a safe way to preview the effect of a risky statement: start a transaction, run the statement, inspect the result on the Data tab, and then roll back if you don't want to keep it.
See also: Committing a transaction · Rolling back to a savepoint