Transactions and ACID Properties

Published July 23, 2025 By Sai Sree Ram Gundepudi

What is a Transaction?

A transaction is a unit of work that is either fully completed or fully rolled back.

ACID Properties:

  • Atomicity: All operations succeed or none
  • Consistency: Database remains valid before and after
  • Isolation: Transactions don't interfere
  • Durability: Once committed, it stays

Example:

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

Was this solution helpful?

Your feedback helps improve our technical knowledge repository.

Share this article