↑↓ select ↵ open ⌫ change scope Open full search

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

Reference / Lock Modes / Row lock

Row lock · FNKU

FOR NO KEY UPDATE

Current

Definition

Behaves similarly to FOR UPDATE, except that the lock acquired is weaker: this lock will not block SELECT FOR KEY SHARE commands that attempt to acquire a lock on the same rows. This lock mode is also acquired by any UPDATE that does not acquire a FOR UPDATE lock.

Compatibility

Compare different transactions holding locks on the same row.

· Compatible modes

View the full compatibility matrices

Commands acquiring this mode

SQL commandObject, phase and conditions
SELECT FOR NO KEY UPDATELock selected rows, with ROW SHARE on the target table. NOWAIT and SKIP LOCKED affect waiting, not mode compatibility. Source
UPDATE (non-key update)UPDATE uses this mode when it does not require FOR UPDATE. Key columns are columns of a unique index usable by a foreign key; partial and expression indexes do not qualify. Source
MERGE … WHEN MATCHED THEN UPDATE (non-key)The UPDATE branch actually runs and does not need FOR UPDATE. Other MERGE actions can require different row locks. Source
INSERT … ON CONFLICT DO UPDATE (non-key)Lock the existing conflicting row for UPDATE, even when the DO UPDATE WHERE condition excludes the update. Key-column changes determine the mode. 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.