↑↓ 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 · RX

ROW EXCLUSIVE

Current

Definition

Conflicts with the SHARE, SHARE ROW EXCLUSIVE, EXCLUSIVE, and ACCESS EXCLUSIVE lock modes.

The commands UPDATE, DELETE, INSERT, and MERGE acquire this lock mode on the target table (in addition to ACCESS SHARE locks on any other referenced tables). In general, this lock mode will be acquired by any command that modifies data in a table.

Compatibility

Compare different transactions holding locks on the same table.

View the full compatibility matrices

Commands acquiring this mode

SQL commandObject, phase and conditions
INSERTLock the insertion target. Inserting a new row is not equivalent to locking an existing row FOR UPDATE. Source
UPDATELock the target table; affected existing rows also receive row locks. Source
DELETELock the target table; deleted rows also receive FOR UPDATE locks. Source
COPY … FROMLock the target and insert new rows. This does not generally lock existing rows FOR UPDATE. Source
MERGELock the target table. Row locking depends on the INSERT, UPDATE or DELETE action actually taken. Source
LOCK TABLE … IN ROW EXCLUSIVE MODERequest this table mode explicitly. Omitting IN MODE defaults to ACCESS EXCLUSIVE. Source
UPDATE (non-key update)This write variant takes ROW EXCLUSIVE on its target table. Existing-row locks depend on the action actually performed. Source
UPDATE (key update)This write variant takes ROW EXCLUSIVE on its target table. Existing-row locks depend on the action actually performed. Source
MERGE … WHEN MATCHED THEN UPDATE (non-key)This write variant takes ROW EXCLUSIVE on its target table. Existing-row locks depend on the action actually performed. Source
MERGE … WHEN MATCHED THEN DELETE / UPDATE (key)This write variant takes ROW EXCLUSIVE on its target table. Existing-row locks depend on the action actually performed. Source
INSERT … ON CONFLICT DO UPDATE (non-key)This write variant takes ROW EXCLUSIVE on its target table. Existing-row locks depend on the action actually performed. Source
INSERT … ON CONFLICT DO UPDATE (key)This write variant takes ROW EXCLUSIVE on its target table. Existing-row locks depend on the action actually performed. Source
INSERT (foreign-key check)The write target takes ROW EXCLUSIVE. The foreign-key check takes ROW SHARE and FOR KEY SHARE on a different object: the referenced table and its matching rows. Source
UPDATE (foreign-key check)The write target takes ROW EXCLUSIVE. The foreign-key check takes ROW SHARE and FOR KEY SHARE on a different object: the referenced table and its matching rows. Source
COPY … FROM (foreign-key check)The write target takes ROW EXCLUSIVE. The foreign-key check takes ROW SHARE and FOR KEY SHARE on a different object: the referenced table and its matching rows. Source
MERGE (foreign-key check)The write target takes ROW EXCLUSIVE. The foreign-key check takes ROW SHARE and FOR KEY SHARE on a different object: the referenced table and its matching rows. 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.