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

ACCESS EXCLUSIVE

Current

Definition

Conflicts with locks of all modes (ACCESS SHARE, ROW SHARE, ROW EXCLUSIVE, SHARE UPDATE EXCLUSIVE, SHARE, SHARE ROW EXCLUSIVE, EXCLUSIVE, and ACCESS EXCLUSIVE). This mode guarantees that the holder is the only transaction accessing the table in any way.

Acquired by the DROP TABLE, TRUNCATE, REINDEX, CLUSTER, VACUUM FULL, and REFRESH MATERIALIZED VIEW (without CONCURRENTLY) commands. Many forms of ALTER INDEX and ALTER TABLE also acquire a lock at this level. This is also the default lock mode for LOCK TABLE statements that do not specify a mode explicitly.

Compatibility

Compare different transactions holding locks on the same table.

· Compatible modes

  • Conflicts with every mode in this scope.

View the full compatibility matrices

Commands acquiring this mode

SQL commandObject, phase and conditions
REFRESH MATERIALIZED VIEW (without CONCURRENTLY)Lock the materialized view, blocking ordinary reads as well. Source
DROP TABLELock the table being dropped. Dependencies and CASCADE can require additional locks. Source
DROP INDEX (without CONCURRENTLY)Take ACCESS EXCLUSIVE on the parent table, blocking reads and writes; the index is locked too. Source
TRUNCATELock each table being truncated. Options and dependencies determine the affected table set. Source
CLUSTERBlock concurrent reads and writes while rewriting the table. Source
VACUUM FULLBlock concurrent reads and writes while rewriting the table. Source
VACUUM (tail truncation)Ordinary VACUUM briefly attempts ACCESS EXCLUSIVE when returning empty tail pages to the operating system. Where supported, disabling truncation avoids this phase. Source
REINDEX (index being rebuilt)Lock the index itself. Planning also accesses indexes, so ordinary REINDEX can still block queries. Source
LOCK TABLE … IN ACCESS EXCLUSIVE MODERequest this table mode explicitly. Omitting IN MODE defaults to ACCESS EXCLUSIVE. Source
ALTER TABLE … ADD COLUMNA rewrite depends on version and default expression. Avoiding the rewrite does not reduce the listed lock mode. Source
ALTER TABLE … DROP COLUMNDrop a column and change the table definition. Source
ALTER TABLE … ALTER COLUMN … SET / DROP DEFAULTChange the column default. Source
ALTER TABLE … ALTER COLUMN … TYPEChange the column type. Whether a rewrite is needed does not change this lock requirement. Source
ALTER TABLE … ALTER COLUMN … SET STORAGEChange the column storage strategy. Source
ALTER TABLE … ALTER COLUMN … SET COMPRESSIONChange the column compression method. Source
ALTER TABLE … SET TABLESPACEMove the table to another tablespace. Source
ALTER TABLE … SET LOGGED / UNLOGGEDChange table persistence. Source
ALTER TABLE … SET ACCESS METHODChange the table access method. Source
ALTER TABLE … DROP CONSTRAINTDrop the constraint and any dependent index as applicable. Source
ALTER TABLE … ALTER CONSTRAINTChange constraint properties. Source
ALTER TABLE … ALTER COLUMN … SET NOT NULLSet a not-null constraint. Source
ALTER TABLE … ALTER COLUMN … DROP NOT NULLDrop a not-null constraint. Source
ALTER TABLE … ENABLE / DISABLE RULEEnable or disable rules. Source
ALTER TABLE … ENABLE / DISABLE ROW LEVEL SECURITYEnable or disable row-level security. Source
ALTER TABLE … FORCE / NO FORCE ROW LEVEL SECURITYChange whether the table owner is subject to row-level security. Source
ALTER TABLE … ALTER COLUMN … DROP EXPRESSIONDrop a generated-column expression. Source
ALTER TABLE … ALTER COLUMN … SET EXPRESSIONSet a generated-column expression. Source
ALTER TABLE … ALTER COLUMN … SET GENERATED / RESTART / SET sequence_optionChange identity-column properties or its implicit sequence options. This is not a standalone SET SEQUENCE subcommand. Source
ALTER TABLE … ALTER COLUMN … ADD GENERATED … AS IDENTITYAdd identity properties to a column. Source
ALTER TABLE … ALTER COLUMN … DROP IDENTITYDrop identity properties. Source
ALTER TABLE … INHERIT / NO INHERIT (child table)This entry describes the altered child table; the inheritance parent is locked separately. Source
ALTER TABLE … OWNER TOChange table ownership. Source
ALTER TABLE … REPLICA IDENTITYChange replica identity. Source
ALTER TABLE … RENAMERename the table, column or constraint. Source
ALTER TABLE … ADD CONSTRAINT (CHECK / UNIQUE / PRIMARY KEY / EXCLUDE)Ordinary constraint creation. Adding a foreign key instead uses SHARE ROW EXCLUSIVE. Source
ALTER TABLE … ATTACH PARTITION (partition being attached)The table being attached requires ACCESS EXCLUSIVE. An appropriate CHECK constraint can avoid a validation scan but not this lock. Source
ALTER TABLE … ATTACH PARTITION (default partition)From PostgreSQL 11, an existing default partition requires ACCESS EXCLUSIVE. An appropriate CHECK constraint can avoid a scan but not the lock on the default partition. Descendant scanning follows validation needs. Source
ALTER TABLE … DETACH PARTITION (parent table)Ordinary detach without CONCURRENTLY. Source
ALTER TABLE … DETACH PARTITION (partition being detached)Ordinary detach takes ACCESS EXCLUSIVE on the partition being detached. Source
ALTER TABLE … DETACH PARTITION … CONCURRENTLY (partition, final phase)The second phase takes ACCESS EXCLUSIVE on the detached partition. CONCURRENTLY is not allowed when a default partition exists. Source
ALTER INDEX … SET TABLESPACELock the index being moved, not the similarly named table. Source
ALTER INDEX … SET / RESET (fillfactor = …)Lock the index being modified. Source
ALTER INDEX … ATTACH PARTITIONFrom PostgreSQL 11, modify the partitioned parent index and the child index being attached. 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.