Reference / Lock Modes / Table lock
Table lock · RX
ROW EXCLUSIVE
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.
× Conflicting modes
· Compatible modes
Commands acquiring this mode
| SQL command | Object, phase and conditions |
|---|---|
| INSERT | Lock the insertion target. Inserting a new row is not equivalent to locking an existing row FOR UPDATE. Source |
| UPDATE | Lock the target table; affected existing rows also receive row locks. Source |
| DELETE | Lock the target table; deleted rows also receive FOR UPDATE locks. Source |
| COPY … FROM | Lock the target and insert new rows. This does not generally lock existing rows FOR UPDATE. Source |
| MERGE | Lock the target table. Row locking depends on the INSERT, UPDATE or DELETE action actually taken. Source |
| LOCK TABLE … IN ROW EXCLUSIVE MODE | Request 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
- Manual source: explicit locking 753057e340da
- Table lock conflict definitions 753057e340da
- Row lock mode definitions 753057e340da
Source collection date: 2026-09-27.