Transaction isolation levels

A transaction isolation level can be set by the developer by invoking the following SQL statement:

SET TRANSACTION ISOLATION LEVEL { SERIALIZABLE | REPEATABLE READ | READ COMMITTED | READ UNCOMMITTED}

The SET TRANSACTION ISOLATION LEVEL statement should be called inside a transaction block before any query, otherwise, it will have no effect. An alternative is to use the following syntax:

BEGIN TRANSACTION ISOLATION LEVEL { SERIALIZABLE | REPEATABLE READ | READ COMMITTED | READ UNCOMMITTED}

Finally, one can change the whole default database isolation level to SERIALIZABLE as follows:

ALTER DATABASE <DATABASE NAME> SET DEFAULT_TRANSACTION_ISOLATION TO SERIALIZABLE ;

As shown by the preceding SQL statement, the transaction ...

Get Learning PostgreSQL 10 - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.