↑↓ select ↵ open ⌫ change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Reference / Lock Modes / Table lock

Table lock · RS

ROW SHARE

Current

Definition

Conflicts with the EXCLUSIVE and ACCESS EXCLUSIVE lock modes.

The SELECT command acquires a lock of this mode on all tables on which one of the FOR UPDATE, FOR NO KEY UPDATE, FOR SHARE, or FOR KEY SHARE options is specified (in addition to ACCESS SHARE locks on any other tables that are referenced without any explicit FOR ... locking option).

Compatibility

Compare different transactions holding locks on the same table.

View the full compatibility matrices

Commands acquiring this mode

SQL commandObject, phase and conditions
SELECT FOR KEY SHARELock the named table, in addition to the corresponding locks on selected rows. Source
SELECT FOR SHARELock the named table, in addition to the corresponding locks on selected rows. Source
SELECT FOR NO KEY UPDATELock the named table, in addition to the corresponding locks on selected rows. Source
SELECT FOR UPDATELock the named table, in addition to the corresponding locks on selected rows. Source
INSERT (foreign-key check)The foreign-key check runs SELECT FOR KEY SHARE on the referenced table, taking ROW SHARE there. The writing target separately holds ROW EXCLUSIVE. Source
UPDATE (foreign-key check)The foreign-key check runs SELECT FOR KEY SHARE on the referenced table, taking ROW SHARE there. The writing target separately holds ROW EXCLUSIVE. Source
COPY … FROM (foreign-key check)The foreign-key check runs SELECT FOR KEY SHARE on the referenced table, taking ROW SHARE there. The writing target separately holds ROW EXCLUSIVE. Source
MERGE (foreign-key check)The foreign-key check runs SELECT FOR KEY SHARE on the referenced table, taking ROW SHARE there. The writing target separately holds ROW EXCLUSIVE. Source
LOCK TABLE … IN ROW SHARE MODERequest this table mode explicitly. Omitting IN MODE defaults to ACCESS EXCLUSIVE. Source
ALTER TABLE … VALIDATE CONSTRAINT (referenced table)Foreign-key validation takes ROW SHARE on the referenced table and SHARE UPDATE EXCLUSIVE on the table being validated. Source

Commands may acquire additional locks. See all command associations.

Other lock modes

Sources

PostgreSQL 18 · Sampled build REL_18_STABLE · 753057e340da. Conflicts, definitions and command associations refer to this fixed source build. SQL links retain the selected version.

Local English manual · Online manual

Pinned source files

Source collection date: 2026-09-27.