Name

RELEASE SAVEPOINT Statement

Synopsis

The RELEASE SAVEPOINT statement eliminates one or more previously created savepoints in the current transaction.

Platform

Command

DB2

Supported, with variations

MySQL

Not supported

Oracle

Not supported

PostgreSQL

Not supported

SQL Server

Not supported

SQL2003 Syntax

RELEASE SAVEPOINT savepoint_name

Keywords

savepoint_name

Represents a named savepoint (or target specification) created earlier in the transaction with the SAVEPOINT statement. The savepoint_name must be unique within the transaction.

Rules at a Glance

Use the RELEASE SAVEPOINT statement within a transaction to destroy a named savepoint. Any savepoints that were created after the named savepoint will also be destroyed.

To illustrate the behavior of savepoints, the following example code inserts a few records, creates a savepoint named first_savepoint, and then releases it:

INSERT authors (au_id, au_lname, au_fname, contract )
VALUES ('111-11-1111', 'Rabbit', 'Jessica', 1);
SAVEPOINT first_savepoint;
INSERT authors (au_id, au_lname, au_fname, contract )
VALUES ('277-27-2777', 'Fudd', 'E.P.', 1);
INSERT authors (au_id, au_lname, au_fname, contract )
VALUES ('366-36-3636', 'Duck', 'P.J.', 1);
RELEASE SAVEPOINT first_savepoint;
COMMIT;

In this example, the first_savepoint savepoint is destroyed and then all three records are inserted into the authors table.

In the next example, we perform the same action but with more savepoints:

INSERT authors (au_id, au_lname, au_fname, contract ...

Get SQL in a Nutshell, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.