transaction

Snapshot isolation

PostgreSQL repeatable read provides snapshot isolation, not full serializability. A stable snapshot does not guarantee cross-row business invariants. Target: PostgreSQL 17. Example is a connection-specific schedule, not a single executable script.

Formal Syntax & Structure

sql syntaxsql
BEGIN ISOLATION LEVEL REPEATABLE READ

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 COUNT(*) FROM t;-- B: INSERT INTO t VALUES(3,10);-- A: SELECT COUNT(*) FROM t;-- Roll back any open transactions after observation.
SQL Reference