Transactions
A transaction is a group of SQL operations that either all succeed or all fail. This chapter introduces transaction usage.
ACID Properties
- Atomicity: All or nothing
- Consistency: Data remains consistent
- Isolation: Transactions are isolated
- Durability: Changes are permanent after commit
Basic Syntax
Transfer Example
Isolation Levels
Savepoints
Best Practices
- Keep transactions short
- Avoid user interaction
- Set appropriate isolation level
- Handle deadlocks
- Use indexes to reduce locking
Summary
- Transactions ensure data consistency
- ACID properties
- BEGIN/COMMIT/ROLLBACK
- Isolation levels
- Savepoints
Next Step: Learn DATABASE-DESIGN