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

SHARE UPDATE EXCLUSIVE

Current

Definition

Conflicts with the SHARE UPDATE EXCLUSIVE, SHARE, SHARE ROW EXCLUSIVE, EXCLUSIVE, and ACCESS EXCLUSIVE lock modes. This mode protects a table against concurrent schema changes and VACUUM runs.

Acquired by VACUUM (without FULL), ANALYZE, CREATE INDEX CONCURRENTLY, CREATE STATISTICS, COMMENT ON, REINDEX CONCURRENTLY, and certain ALTER INDEX and ALTER TABLE variants (for full details see the documentation of these commands).

Compatibility

Compare different transactions holding locks on the same table.

View the full compatibility matrices

Commands acquiring this mode

SQL commandObject, phase and conditions
VACUUM (without FULL)Ordinary vacuum holds this mode; truncating empty tail pages can briefly require ACCESS EXCLUSIVE. Source
ANALYZELock the table being analyzed. Source
CREATE INDEX CONCURRENTLYLock the indexed table. Building proceeds across transactions and waits for old transactions where necessary. Source
CREATE STATISTICSLock the table whose extended statistics are being defined. Source
COMMENT ON (relation object)Lock the object being commented on. Identical modes on different objects do not conflict. Source
DROP INDEX CONCURRENTLYLock the parent table while removing the index across phases; unlike ordinary DROP INDEX this does not hold ACCESS EXCLUSIVE on the table. Source
REINDEX … CONCURRENTLYFrom PostgreSQL 12, session-level SHARE UPDATE EXCLUSIVE locks cover the rebuilt index and its table through the build, validation, swap and cleanup transactions. Source
LOCK TABLE … IN SHARE UPDATE EXCLUSIVE MODERequest this table mode explicitly. Omitting IN MODE defaults to ACCESS EXCLUSIVE. Source
ALTER TABLE … ALTER COLUMN … SET STATISTICSChange the column statistics target. Source
ALTER TABLE … ALTER COLUMN … SET (n_distinct = …)Change column statistics options; RESET has the same requirement. Source
ALTER TABLE … CLUSTER ONChoose the index for future clustering; this command does not rewrite the table. Source
ALTER TABLE … SET WITHOUT CLUSTERClear the clustering-index designation. Source
ALTER TABLE … VALIDATE CONSTRAINTValidate a constraint on this table. Foreign-key validation also accesses the referenced table. Source
ALTER TABLE … ATTACH PARTITION (parent table)The parent lock is extracted separately for every version. The table being attached additionally requires ACCESS EXCLUSIVE. From PostgreSQL 11 a default partition, if any, is also locked. Source
ALTER TABLE … DETACH PARTITION … FINALIZE (parent table)Complete an interrupted concurrent detach. The detached partition additionally requires ACCESS EXCLUSIVE. Source
ALTER TABLE … SET / RESET (fillfactor = …)Each storage parameter specifies its required mode. fillfactor can use SHARE UPDATE EXCLUSIVE. Source
ALTER TABLE … SET / RESET (autovacuum_* = …)Table autovacuum storage options use SHARE UPDATE EXCLUSIVE. Source
ALTER TABLE … SET / RESET (toast.autovacuum_* = …)These are TOAST autovacuum options. There is no generic SET TOAST subcommand; other options follow their own lock requirements. Source
ALTER TABLE … DETACH PARTITION … CONCURRENTLY (parent table)From PostgreSQL 14, concurrent detach uses two transactions. The parent holds SHARE UPDATE EXCLUSIVE and waits for transactions using the partition before finalizing. Source
ALTER TABLE … DETACH PARTITION … CONCURRENTLY (partition, first phase)In the first phase, parent and partition hold SHARE UPDATE EXCLUSIVE. The partition lock is upgraded after committing and waiting. Source
ALTER INDEX … RENAMELock the index being renamed. Source
ALTER TABLE … INHERIT (parent table)Take SHARE UPDATE EXCLUSIVE on the newly designated parent. The altered child separately takes ACCESS EXCLUSIVE. 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.