Interview Q&A / SQL & DBMS

BeginnerQuick answer1 min readUpdated 3 Oct 2026

What do COMMIT, ROLLBACK and SAVEPOINT do?

SHORT ANSWER

COMMIT makes a transaction's changes permanent. ROLLBACK undoes everything since the transaction began. SAVEPOINT marks a point inside a transaction so you can roll back only part of it.

Explain it simply

Editing a document: COMMIT is pressing Save, ROLLBACK is closing without saving, and SAVEPOINT is a checkpoint you can return to without losing the earlier edits.

Example

sql
BEGIN;

UPDATE accounts SET balance = balance - 500 WHERE id = 1;
SAVEPOINT after_debit;

UPDATE accounts SET balance = balance + 500 WHERE id = 99;
-- oops, wrong account

ROLLBACK TO after_debit;   -- undoes only the second update

UPDATE accounts SET balance = balance + 500 WHERE id = 2;
COMMIT;                    -- debit and the correct credit become permanent
  • Before COMMIT, other sessions do not see these changes (depending on isolation level).
  • After COMMIT, the changes survive a crash because of durability.
  • After a full ROLLBACK, the database is as it was at BEGIN.
  • START TRANSACTION in MySQL and BEGIN TRANSACTION in SQL Server start a transaction.

DDL such as CREATE or DROP commits implicitly in MySQL and Oracle, so it cannot be rolled back there. PostgreSQL supports transactional DDL.

What to say in the interview

"COMMIT saves, ROLLBACK undoes the whole transaction, and SAVEPOINT allows a partial rollback. Together they let a multi-step operation like a money transfer succeed or fail as one unit."

Common mistakes

  • Forgetting to COMMIT and leaving locks open for other sessions.

#sql#transactions#commit#rollback

Related questions

Practise more SQL & DBMS questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open SQL & DBMS quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.