What is a savepoint in a transaction, and how do COMMIT, ROLLBACK, and SAVEPOINT work together?
Last updated
A savepoint is a named marker inside a transaction.
ROLLBACK TO SAVEPOINT nameundoes only work after it while keeping the transaction open.COMMITpersists all surviving changes and releases savepoints. A plainROLLBACKaborts the entire transaction.Typical use: try a risky step, and if it fails, roll back to just before it and continue without losing the whole unit of work.
- https://www.postgresql.org/docs/current/sql-rollback-to.html
- https://www.postgresql.org/docs/current/sql-savepoint.html
- https://dev.mysql.com/doc/en/savepoint.html
- https://learn.microsoft.com/en-us/sql/t-sql/language-elements/save-transaction-transact-sql?view=sql-server-ver17
- https://dev.to/luca1iu/sql-transactions-commit-rollback-and-savepoints-with-python-1f7a
- https://medium.com/@AlexanderObregon/savepoints-in-sql-transactions-e22b13cfba16
- https://www.geeksforgeeks.org/sql/sql-transactions/
- https://oneuptime.com/blog/post/2026-03-31-mysql-how-to-use-rollback-to-savepoint-in-mysql/view