SQL Interview Question

What is a transaction in SQL and what is ACID?

Updated 2026-07-10 · Beginner friendly
Quick answer

A transaction is a group of SQL statements that must succeed or fail as a single unit. If any part fails, the whole transaction is rolled back so the database stays consistent. Transactions follow the ACID properties: atomicity, consistency, isolation, and durability, which guarantee reliable data even during errors or crashes.

The classic example

Transferring money means subtracting from one account and adding to another. If the first step succeeds but the second fails, money would vanish. A transaction ensures both steps happen together or neither does.

BEGIN;
UPDATE accounts SET balance = balance - 100 WHERE id = 1;
UPDATE accounts SET balance = balance + 100 WHERE id = 2;
COMMIT;   -- both succeed, or ROLLBACK undoes everything

The ACID properties

In the interview

Lead with the bank transfer example, then name the ACID letters. A concrete story followed by the four properties is far more convincing than reciting definitions alone.

Want the full SQL guide?

Read every SQL concept with notes, diagrams, and code in one place. Track your progress as you go.

Open the SQL guide All SQL questions