PostgreSQL Advanced Cheat Sheet/Rollback transaction

Discard all uncommitted work.

Section: Transactions, Savepoints, and Locking

Rollback transaction

sql
sql
ROLLBACK;
Explanation

See summary for usage details.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Transactions, Savepoints, and Locking
Begin transaction
Start an explicit transaction block.
OpenIn sheetsqlsame section
Commit transaction
Persist all changes in the current transaction.
OpenIn sheetsqlsame section
Create savepoint
Mark a partial rollback point within a transaction.
OpenIn sheetsqlsame section
Rollback to savepoint
Undo work after the named savepoint while keeping the transaction open.
OpenIn sheetsqlsame section
Lock table
Acquire an explicit table lock.
OpenIn sheetsqlsame section
Set isolation level
Change isolation for the current transaction.
OpenIn sheetsqlsame section