ROLLBACK
abort the current transaction
English manual coverage begins with PostgreSQL 6.4. Source history and runtime observations have their own recorded version boundaries.
Reading PG 18·Select a recorded version
- anchor
- SQL-ROLLBACK
- file
- sql-rollback.html
- lang
- en
- name
- ROLLBACK
- purpose
- abort the current transaction
- purpose zh
- 中止当前事务
- sections same as
- Unknown
- slug
- 18
- synopsis html
- ROLLBACK [ WORK | TRANSACTION ] [ AND [ NO ] CHAIN ]
- synopsis text
- ROLLBACK [ WORK | TRANSACTION ] [ AND [ NO ] CHAIN ]
Syntax
ROLLBACK [ WORK | TRANSACTION ] [ AND [ NO ] CHAIN ]Syntax diagrams
Read left to right. Branches are choices, bypasses are optional, loops repeat. Select an underlined parameter to open its rule.
Definition PG 18
ROLLBACK [ WORK | TRANSACTION ] [ AND [ NO ] CHAIN ]
Description
ROLLBACK rolls back the current transaction and causes all the updates made by the transaction to be discarded.
Parameters
WORKTRANSACTIONOptional key words. They have no effect.
AND CHAINIf
AND CHAINis specified, a new (not aborted) transaction is immediately started with the same transaction characteristics (see SET TRANSACTION) as the just finished one. Otherwise, no new transaction is started.
Notes
Use COMMIT to successfully terminate a transaction.
Issuing ROLLBACK outside of a transaction block emits a warning and otherwise has no effect. ROLLBACK AND CHAIN outside of a transaction block is an error.
Examples
To abort all changes:
ROLLBACK;
Compatibility
The command ROLLBACK conforms to the SQL standard. The form ROLLBACK TRANSACTION is a PostgreSQL extension.
See Also
BEGIN, COMMIT, ROLLBACK TO SAVEPOINTCompare versions
Source references
Full definition and evidence JSON
Definition sources
center · PostgreSQL 18 · wiki-repair-20261023:93225a29f342291148b6f0f592fe12e5a74edfeb0a9a68495ebb5ac59bed3546
Text language: en · wiki-repair-20261023:93225a29f342291148b6f0f592fe12e5a74edfeb0a9a68495ebb5ac59bed3546