Skip to Main Content
SQL in a Nutshell
book

SQL in a Nutshell

by Kevin Kline
December 2000
Intermediate to advanced content levelIntermediate to advanced
224 pages
9h 52m
English
O'Reilly Media, Inc.
Content preview from SQL in a Nutshell

Name

ROLLBACK

Synopsis

The ROLLBACK statement undoes a transaction to its beginning or a previously declared SAVEPOINT. It closes open cursors and releases locks in the same way as COMMIT.

Vendor

Command

SQL Server

Supported, with variations

MySQL

Not supported

Oracle

Supported

PostgreSQL

Supported

SQL99 Syntax and Description

ROLLBACK [WORK]
[TO SAVEPOINT savepoint_name]

In addition to finalizing a single or group of data-manipulation operations, the ROLLBACK statement undoes transactions up to the last issued BEGIN or SAVEPOINT statement.

SQL99 offers the new, optional keywords AND CHAIN. None of the four vendors yet support this command. This new syntax is:

ROLLBACK [WORK] [AND [NO] CHAIN]

The AND CHAIN option tells the DBMS to end the current transaction, but to share the common transaction environment (such as transaction isolation level) with the next transaction. The AND NO CHAIN option simply ends the single transaction. The ROLLBACK command is functionally equivalent to the command, ROLLBACK WORK AND NO CHAIN.

Microsoft SQL Server Syntax and Variations

ROLLBACK [TRAN[SACTION] [transaction_name |
 @tran_name_variable |
savepoint_name | @savepoint_variable] ]

ROLLBACK clears all data modifications made to the current open transaction or to a specific, existing savepoint. If ROLLBACK is issued alone, it rolls back the current open transaction. ROLLBACK normally frees locks, but it does not free locks when rolling back to a savepoint. ROLLBACK behaves similarly to COMMIT ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

SQL in a Nutshell, 3rd Edition

SQL in a Nutshell, 3rd Edition

Kevin Kline

Publisher Resources

ISBN: 1565927443