Reference / Lock Modes / Row lock
Row lock · FKS
FOR KEY SHARE
Definition
Behaves similarly to FOR SHARE, except that the lock is weaker: SELECT FOR UPDATE is blocked, but not SELECT FOR NO KEY UPDATE. A key-shared lock blocks other transactions from performing DELETE or any UPDATE that changes the key values, but not other UPDATE, and neither does it prevent SELECT FOR NO KEY UPDATE, SELECT FOR SHARE, or SELECT FOR KEY SHARE.
Compatibility
Compare different transactions holding locks on the same row.
× Conflicting modes
· Compatible modes
Commands acquiring this mode
| SQL command | Object, phase and conditions |
|---|---|
| SELECT FOR KEY SHARE | Lock selected rows, with ROW SHARE on the target table. NOWAIT and SKIP LOCKED affect waiting, not mode compatibility. Source |
| INSERT (foreign-key check) | Checking a non-null foreign key locks matching rows in the referenced table FOR KEY SHARE. The check can run immediately or be deferred. Cascading actions require their own UPDATE or DELETE locks. Source |
| UPDATE (foreign-key check) | Checking a non-null foreign key locks matching rows in the referenced table FOR KEY SHARE. The check can run immediately or be deferred. Cascading actions require their own UPDATE or DELETE locks. Source |
| COPY … FROM (foreign-key check) | Checking a non-null foreign key locks matching rows in the referenced table FOR KEY SHARE. The check can run immediately or be deferred. Cascading actions require their own UPDATE or DELETE locks. Source |
| MERGE (foreign-key check) | Checking a non-null foreign key locks matching rows in the referenced table FOR KEY SHARE. The check can run immediately or be deferred. Cascading actions require their own UPDATE or DELETE locks. 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.