Lesson 17: Transactions & ACID
18 Jul 2026 1 min Swarnil Singhai
A transaction bundles multiple statements so they all succeed or all roll back together — the same guarantee that keeps bank transfers correct.
Real-time example
Moving money between two accounts must debit one and credit the other atomically, or the bank loses/creates money.
BEGIN;
UPDATE accounts SET balance = balance - 500 WHERE id = 1;
UPDATE accounts SET balance = balance + 500 WHERE id = 2;
COMMIT;
-- if anything fails before COMMIT: ROLLBACK;
What's happening
Nothing is visible to other connections until COMMIT — if the process crashes mid-transaction, the database rolls it back automatically.
ACID — Atomicity, Consistency, Isolation, Durability — is the theoretical backing for exactly this guarantee.
Advertisement