Extras · Lesson 7 of 22

Transactions & ACID

Transactions group operations that must succeed or fail together.

Transfer money between accounts:

BEGIN TRANSACTION;
UPDATE accounts SET balance = balance - 100 WHERE id = 1;
UPDATE accounts SET balance = balance + 100 WHERE id = 2;
COMMIT;

ACID properties:

  • Atomicity - all or nothing
  • Consistency - rules always enforced
  • Isolation - transactions don't interfere
  • Durability - committed = permanent

If anything fails, ROLLBACK undoes everything.

Critical for: banking, e-commerce, any financial data.

Check your understanding

What does 'Atomicity' mean in ACID?

Practice it on a real question

All SELECT & filtering questions

Practice on your iPhone

Query Dojo for iPhone has 85 interview questions, timed mock interviews and a tile builder, so you can write queries without a keyboard.

Get the app