Database transaction Created 2026-10-31 Updated 2026-11-05
A database transaction groups database operations into a unit that can be committed or rolled back. Transaction atomicity means that its updates take effect together or not at all. Transaction durability concerns retaining an acknowledged committed result after a failure; transaction isolation controls which effects concurrent database transactions may observe.[ref]
For example, transferring seven units from an account with balance twenty to one with balance five should produce balances thirteen and twelve. A failure after only the debit must not leave thirteen and five as a completed transfer. In SQL, a transaction block uses BEGIN, then the related updates, then COMMIT; ROLLBACK abandons the uncommitted changes.[ref]
Isolation is a separate question from grouping statements. Two concurrent transfers can each read an old balance before either writes. A correct application must select suitable transaction isolation or locking and handle possible conflicts; merely putting the statements in a database transaction does not establish every desired invariant. The corresponding database schedule records their interleaving.
The PostgreSQL Global Development Group is the collective project attribution used for the development and documentation of PostgreSQL, an open-source database management system. Its documentation specifies concrete behavior for database transactions, database integrity constraints, database query operations and storage mechanisms; these specifications are more precise than inferring behavior from SQL syntax alone.[ref]
For example, PostgreSQL documents transaction isolation levels in terms of visible snapshots and permitted anomalies. The project name here identifies the responsible development community, rather than one individual author or a separate database product.
Transaction atomicity 2026-11-05
Transaction atomicity gives a database transaction an all-or-nothing effect: either its committed updates take effect together or its partial updates do not remain as a completed result. This can be implemented with undo information, version visibility, recovery logging or combinations of these mechanisms. It does not require every physical write to happen at the same instant.
For example, transferring five units between accounts requires a debit and a credit. If an error occurs after the debit, aborting the transaction must not leave only that debit as the final database result. SQL transaction blocks use BEGIN, COMMIT and ROLLBACK to express the boundary.[ref] Atomicity alone does not say how transactions interact before completion; transaction isolation governs that. Nor does it make a committed result survive a crash; that is transaction durability. External effects such as a sent email require coordination beyond rolling back the database changes.
Transaction isolation 2026-11-05
Transaction isolation specifies which effects concurrent database transactions may observe and which interleavings are permitted to commit. Serializable isolation requires the combined result to be equivalent to some serial ordering, even when execution actually overlaps. Weaker levels admit particular anomalies; their names require implementation-specific interpretation.[ref]
For example, two doctors are on call. Each transaction reads that both are available and removes its own doctor, intending to leave someone on call. If each sees an old snapshot and they update different rows, both may commit under a snapshot-based level that does not prevent this write skew. No serial ordering would let both checks pass. PostgreSQL Serializable can reject such conflicting executions, so the application must be prepared to retry a whole transaction. Isolation protects a stated concurrency model; it does not repair a faulty business rule within one transaction.