Skip to Main Content
Practical PostgreSQL
book

Practical PostgreSQL

by Joshua D. Drake, John C. Worsley
January 2002
Intermediate to advanced content levelIntermediate to advanced
640 pages
16h 39m
English
O'Reilly Media, Inc.
Content preview from Practical PostgreSQL

Set Transaction

Sets the transaction isolation level for the current transaction block.

Synopsis

SET TRANSACTION ISOLATION LEVEL
    { READ COMMITTED | SERIALIZABLE }
SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL
    { READ COMMITTED | SERIALIZABLE }

Parameters

READ COMMITTED

The clause that specifies that statements will be able to view changes to the database that were committed before the transaction began. This is the default.

SERIALIZABLE

The clause that specifies that statements will be able to view all rows that were committed in the database before the transaction’s first DML statement is executed.

Results

SET VARIABLE

The message returned when the isolation level has been set successfully. To verify that it is correctly set, you can issue the command SHOW TRANSACTION ISOLATION LEVEL, which should then return the variable’s setting (either READ COMMITTED or SERIALIZABLE).

Description

Use the SET TRANSACTION command to set the transaction isolation level for the current transaction. This change will affect only the current transaction; all other subsequent transactions must have their isolation mode explicitly set, otherwise the default of READ COMMITTED will be used.

You can only use this command before the first DML statement has been executed. A DML statement is one of SELECT, INSERT, DELETE, UPDATE, FETCH, or COPY.

To set the default transaction isolation level (as opposed to individual transaction), use SET SESSION CHARACTERISTICS and specify either READ COMMITTED or SERIALIZABLE ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

PostgreSQL: Up and Running, 2nd Edition

PostgreSQL: Up and Running, 2nd Edition

Regina O. Obe, Leo S. Hsu
Learning PostgreSQL 11 - Third Edition

Learning PostgreSQL 11 - Third Edition

Christopher Travers, Andrey Volkov
Learn PostgreSQL

Learn PostgreSQL

Luca Ferrari, Enrico Pirozzi
PostgreSQL 13 Cookbook

PostgreSQL 13 Cookbook

Vallarapu Naga Avinash Kumar

Publisher Resources

ISBN: 9781449309770Supplemental ContentErrata Page