rollback

Rollback (undo) a transaction's changes

Syntax

rollback_stmt:
          ROLLBACK [WORK] [[TO SAVEPOINT] savepoint_id]

Description

The ROLLBACK statement discards (undoes) all changes that have been made to any open databases since the most recent START TRANSACTION statement or, if no START TRANSACTION was issued, since the last COMMIT or ROLLBACK statement was executed, or, if neither a START TRANSACTION, COMMIT, or ROLLBACK have been issued, since the start of the session.

This statement can also be used to rollback the changes that have been made since the savepoint specified by savepoint_id was issued.

This statement is also used to terminate a read only transaction.

Example

start transaction;
 	... /* make some changes to the database */

 	... /* system detects invalid data */
rollback;

See Also

COMMIT

START TRANSACTION