transaction
MVCC
Multiple row versions support snapshot visibility. PostgreSQL readers generally do not block ordinary writers and vice versa; explicit locks and DDL can still block. Old versions need cleanup. Target: PostgreSQL 17. Example is a connection-specific schedule, not a single executable script.
Formal Syntax & Structure
sql syntaxsql
SELECT ... (concept)Working Example
Example Snippetsql
-- Fresh fixture: CREATE TABLE t(id INT PRIMARY KEY, n INT NOT NULL);-- INSERT INTO t VALUES (1,10),(2,10);-- Use two independent connections A and B; setup committed first.-- A: BEGIN ISOLATION LEVEL REPEATABLE READ;-- A: SELECT n FROM t WHERE id=1;-- B: UPDATE t SET n=50 WHERE id=1;-- A: SELECT n FROM t WHERE id=1;-- A: COMMIT;-- A: SELECT n FROM t WHERE id=1;-- Roll back any open transactions after observation.