LearnThatStack Ace your next interview
PostgreSQL · question
Question 1 of 42

Explain the ACID properties in PostgreSQL.

beginner
← All PostgreSQL questions
Re-explain

ACID names four guarantees a transaction gives. PostgreSQL provides them with constraints, multiversion concurrency control (MVCC) snapshots and its write-ahead log (WAL).

  • Atomicity means a transaction is all or nothing. If any statement in it fails, PostgreSQL rolls the whole transaction back, and none of its changes ever become visible.
  • Consistency means every transaction leaves the data valid. PostgreSQL enforces this with constraints such as primary keys, foreign keys and CHECK.
  • Isolation means a transaction does not see the unfinished changes of others. PostgreSQL gives each statement an MVCC snapshot of the data.
  • Durability means a committed change survives a crash. PostgreSQL records the change in the WAL and flushes that log to disk before COMMIT returns.

Outside a BEGIN block, PostgreSQL runs each statement as its own transaction. Wrapping the transfer below in BEGIN and COMMIT makes its two updates one atomic unit.

BEGIN;
UPDATE accounts SET balance = balance - 100 WHERE id = 1;
UPDATE accounts SET balance = balance + 100 WHERE id = 2;
COMMIT; -- Both operations succeed or both fail
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

The diagram below the answer is the concept . Jump to it ↓

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

Saved in this browser - sign in to keep your review list.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Interview lens

Likely follow-ups, what you can say, and the weak answers to avoid.

Sign in free to open it Free account - the lens opens as soon as you're back.

Want a quick review of the fundamentals? See the PostgreSQL cheatsheet.

← Back to all PostgreSQL questions
Pro · $10/mo

37 of 42 PostgreSQL answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime