What is a savepoint in a transaction, and how do COMMIT, ROLLBACK, and SAVEPOINT work together?

Last updated 3 July 2026

  • A savepoint is a named marker inside a transaction. ROLLBACK TO SAVEPOINT name undoes only work after it while keeping the transaction open.

  • COMMIT persists all surviving changes and releases savepoints. A plain ROLLBACK aborts 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
All SQL interview questions