The full answer
A transaction is a group of database operations that succeed or fail as one unit. The ACID properties (atomicity, consistency, isolation and durability) are the guarantees that make that true even with many users and in the middle of crashes.
BEGIN;
UPDATE accounts SET balance = balance - 500 WHERE account_id = 1;
UPDATE accounts SET balance = balance + 500 WHERE account_id = 2;
COMMIT; -- or ROLLBACK; to undo both
| Property | Meaning | Without it |
|---|---|---|
| Atomicity | All statements in the transaction take effect, or none do | Money leaves one account and never arrives in the other |
| Consistency | Each transaction moves the database from one valid state to another; constraints hold at commit | Orders pointing to customers that don't exist |
| Isolation | Concurrent transactions don't see each other's unfinished work, to the degree the isolation level promises | Reports reading half-finished updates; lost updates |
| Durability | Once committed, changes survive crashes and power loss | A confirmed payment disappears after a restart |
How databases provide them
- Atomicity and durability: a write-ahead log records changes before they are applied, so after a crash the database can redo committed work and undo the rest.
- Isolation: locks, multi-version concurrency control (readers see a snapshot), or both.
Isolation levels are a trade-off
- Read committed: each statement sees data committed before it began. The default in PostgreSQL, SQL Server and Oracle.
- Repeatable read: the transaction keeps seeing the same data it read. The default in MySQL's InnoDB.
- Serializable: the result is as if transactions ran one after another; the database may abort a transaction that would break that, so the application must retry. Higher levels prevent more anomalies but cause more waiting or retries. Pick the lowest level that rules out the anomalies your logic can't tolerate, and test what happens when two users act at the same moment.
Why it matters Payments, inventory, bookings and anything else where partial or interleaved updates would cause real harm rely on transactions. Many distributed and NoSQL systems relax some of these guarantees for scale, often offering eventual consistency across replicas, which pushes the work of handling conflicts onto the application.
Last updated 16 October 2026
Sources