ROLLBACK

Name

ROLLBACK  --  Aborts the current transaction

Synopsis

ROLLBACK [ WORK | TRANSACTION ]
  

Inputs

WORK

Optional keyword. Has no effect.

TRANSACTION

Optional keyword. Has no effect.

Outputs

ABORT

Message returned if successful.

NOTICE: ROLLBACK: no transaction in progress

If there is not any transaction currently in progress.

Description

ROLLBACK rolls back the current transaction and causes all the updates made by the transaction to be discarded.

Notes

Use COMMIT to successfully terminate a transaction. ABORT is a synonym for ROLLBACK.

Usage

To abort all changes:
CREATE TABLE t1 (
   i1 integer
);
INSERT INTO t1 (i1) VALUES (1);
INSERT INTO t1 VALUES (2);
BEGIN;
DELETE FROM t1;
ROLLBACK;
SELECT * FROM t1;

   
t1 should contains values 1 and 2

Compatibility

SQL92

SQL92 only specifies the two forms ROLLBACK and ROLLBACK WORK. However, these are implemented in a fully compatible way.