Name
ROLLBACK TRANSACTION — Undo part or all of the current transaction
Syntax
Common Usage
ROLLBACK;
ROLLBACK TO SAVEPOINT savepoint_name
;
Description
The ROLLBACK
command is used to roll back a
transaction state. This is analogous to an undo function for
transactions.
There are two forms of ROLLBACK
. The most basic form
has no TO
clause and causes
the entire transaction to be rolled back. Any and all changes
and modifications made to the database as part of the
transaction are reverted, the transaction is released, and the
database connection is put back into autocommit mode with no
active transaction.
If a TO
clause is provided, the transaction is
rolled back to the state it was in just
after the named save-point was
created. The named save-point will remain on the save-point
stack. You can roll back to any save-point, but if more than one
save-point exists with the same name, the most recent save-point
will be used. After rolling back to a save-point, the original
transaction is still active.
If the named save-point was created outside of a transaction (causing an implicit transaction to be started) the whole transaction will be rolled back, but the save-point and transaction will remain in place.
Get Using SQLite now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.