Skip to main content

What does the term "atomicity" mean?

Atomicity is one of a transaction's properties (the A in ACID), and it means every operation inside a transaction runs as a single unit: either all of them succeed, or none of them runs.

Example:

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

If the first command succeeds but the second one fails (e.g. due to an error), the whole transaction rolls back (ROLLBACK), and the balance on both accounts stays as it was.

Summary: Atomicity guarantees the database never ends up in a "half-done" state - data changes as a whole, completely, or not at all.

Short Answer

Interview ready
Premium

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