SQLIntermediate#transactions

Explain the ACID properties.

Atomicity: a transaction is all-or-nothing. Consistency: it moves the database from one valid state to another. Isolation: concurrent transactions do not corrupt each other. Durability: committed data survives a crash.

Example
BEGIN;
UPDATE accounts SET balance = balance - 500 WHERE id = 1;
UPDATE accounts SET balance = balance + 500 WHERE id = 2;
COMMIT; -- both succeed or neither does

Related Questions

1
SQLAdvanced#transactions

What are transaction isolation levels?

Open
2
SQLAdvanced#transactions

What is a deadlock and how do you avoid it?

Open
3
SQLAdvanced#transactions#concurrency

What are optimistic and pessimistic locking?

Open