ROLLBACK TO SAVEPOINT v15

Name

ROLLBACK TO SAVEPOINT Roll back to a savepoint.

Synopsis

ROLLBACK [ WORK ] TO [ SAVEPOINT ] <savepoint_name>

Description

Roll back all commands that were executed after the savepoint was set. The savepoint remains valid and you can roll back to it again if you need to.

ROLLBACK TO SAVEPOINT destroys all savepoints that were established after the named savepoint.

Parameters

savepoint_name

The savepoint to which to roll back.

Notes

Specifying a savepoint name that wasn't established is an error.

ROLLBACK TO SAVEPOINT isn't supported in SPL programs.

Examples

Undo the effects of the commands executed from the point when savepoint depts was established:

\set AUTOCOMMIT off
INSERT INTO dept VALUES (50, 'HR', 'NEW YORK');
SAVEPOINT depts;
INSERT INTO emp (empno, ename, deptno) VALUES (9001, 'JONES', 50);
INSERT INTO emp (empno, ename, deptno) VALUES (9002, 'ALICE', 50);
ROLLBACK TO SAVEPOINT depts;

See also

COMMIT, ROLLBACK, SAVEPOINT