# Transactions
A **Transaction** in PostgreSQL is a fundamental unit of work that ensures database consistency and integrity. It adheres to the ACID (Atomicity, Consistency, Isolation, Durability) properties.
For the narrative explanation of this concept, see [[Chapter 4/4.4 - The Pinky Swear (Transactions)|4.4 Transactions (The Pinky Swear)]].
## ACID Properties
1. **Atomicity**: Ensures that all operations within a transaction are completed successfully; if any operation fails, the entire transaction is rolled back.
2. **Consistency**: Guarantees that a transaction transforms the database from one valid state to another, maintaining all predefined rules and constraints.
3. **Isolation**: Ensures that the execution of concurrent transactions does not interfere with each other, providing a consistent view of data (see [[Architecture/MVCC|MVCC]]).
4. **Durability**: Guarantees that once a transaction is committed, its changes are permanent, even in the event of a system failure (see [[Architecture/WAL|WAL]]).
## Isolation Levels
PostgreSQL supports the following SQL-standard isolation levels:
- **Read Committed**: The default level where each query within a transaction sees only data committed before that query began.
- **Repeatable Read**: Ensures that the transaction sees only data committed before the transaction began, preventing non-repeatable reads.
- **Serializable**: The strongest isolation level, which ensures that the results of concurrent transactions are identical to some serial execution of those transactions.
## Lifecycle and Commands
- **BEGIN**: Starts a new transaction block.
- **COMMIT**: Saves all changes made during the current transaction and makes them visible to others.
- **ROLLBACK**: Discards all changes made during the current transaction.
- **SAVEPOINT**: Defines a point within a transaction to which you can later roll back without discarding the entire transaction.
## See Also
- [[Architecture/MVCC|MVCC]]
- [[Architecture/WAL|Write-Ahead Logging]]
- [[Workloads/Lock|Locking and Concurrency]]