Skip to main content

What does the COMMIT command do?

The COMMIT command finishes a transaction and saves every change made within it to the database.

After COMMIT, the results become permanent - they can no longer be undone with ROLLBACK.

Example

sql
START TRANSACTION; UPDATE users SET balance = balance - 100 WHERE id = 1; UPDATE users SET balance = balance + 100 WHERE id = 2; COMMIT;

After COMMIT, both changes (the debit and the credit) get committed, and the database treats them as final.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.