PostgreSQL Advanced Cheat Sheet/Rollback to savepoint

Undo work after the named savepoint while keeping the transaction open.

Section: Transactions, Savepoints, and Locking

Rollback to savepoint

sql
sql
ROLLBACK TO SAVEPOINT before_step_two;
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
Create savepoint
Mark a partial rollback point within a transaction.
OpenIn sheetsqlsame section
Begin transaction
Start an explicit transaction block.
OpenIn sheetsqlsame section
Commit transaction
Persist all changes in the current transaction.
OpenIn sheetsqlsame section
Rollback transaction
Discard all uncommitted work.
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