Reference / Lock Modes / Table lock
Table lock · AX
ACCESS EXCLUSIVE
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.
× Conflicting modes
· Compatible modes
- Conflicts with every mode in this scope.
Commands acquiring this mode
| SQL command | Object, phase and conditions |
|---|---|
| REFRESH MATERIALIZED VIEW (without CONCURRENTLY) | Lock the materialized view, blocking ordinary reads as well. Source |
| DROP TABLE | Lock 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 |
| TRUNCATE | Lock each table being truncated. Options and dependencies determine the affected table set. Source |
| CLUSTER | Block concurrent reads and writes while rewriting the table. Source |
| VACUUM FULL | Block 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 MODE | Request this table mode explicitly. Omitting IN MODE defaults to ACCESS EXCLUSIVE. Source |
| ALTER TABLE … ADD COLUMN | A rewrite depends on version and default expression. Avoiding the rewrite does not reduce the listed lock mode. Source |
| ALTER TABLE … DROP COLUMN | Drop a column and change the table definition. Source |
| ALTER TABLE … ALTER COLUMN … SET / DROP DEFAULT | Change the column default. Source |
| ALTER TABLE … ALTER COLUMN … TYPE | Change the column type. Whether a rewrite is needed does not change this lock requirement. Source |
| ALTER TABLE … ALTER COLUMN … SET STORAGE | Change the column storage strategy. Source |
| ALTER TABLE … ALTER COLUMN … SET COMPRESSION | Change the column compression method. Source |
| ALTER TABLE … SET TABLESPACE | Move the table to another tablespace. Source |
| ALTER TABLE … SET LOGGED / UNLOGGED | Change table persistence. Source |
| ALTER TABLE … SET ACCESS METHOD | Change the table access method. Source |
| ALTER TABLE … DROP CONSTRAINT | Drop the constraint and any dependent index as applicable. Source |
| ALTER TABLE … ALTER CONSTRAINT | Change constraint properties. Source |
| ALTER TABLE … ALTER COLUMN … SET NOT NULL | Set a not-null constraint. Source |
| ALTER TABLE … ALTER COLUMN … DROP NOT NULL | Drop a not-null constraint. Source |
| ALTER TABLE … ENABLE / DISABLE RULE | Enable or disable rules. Source |
| ALTER TABLE … ENABLE / DISABLE ROW LEVEL SECURITY | Enable or disable row-level security. Source |
| ALTER TABLE … FORCE / NO FORCE ROW LEVEL SECURITY | Change whether the table owner is subject to row-level security. Source |
| ALTER TABLE … ALTER COLUMN … DROP EXPRESSION | Drop a generated-column expression. Source |
| ALTER TABLE … ALTER COLUMN … SET EXPRESSION | Set a generated-column expression. Source |
| ALTER TABLE … ALTER COLUMN … SET GENERATED / RESTART / SET sequence_option | Change identity-column properties or its implicit sequence options. This is not a standalone SET SEQUENCE subcommand. Source |
| ALTER TABLE … ALTER COLUMN … ADD GENERATED … AS IDENTITY | Add identity properties to a column. Source |
| ALTER TABLE … ALTER COLUMN … DROP IDENTITY | Drop 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 TO | Change table ownership. Source |
| ALTER TABLE … REPLICA IDENTITY | Change replica identity. Source |
| ALTER TABLE … RENAME | Rename 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 TABLESPACE | Lock the index being moved, not the similarly named table. Source |
| ALTER INDEX … SET / RESET (fillfactor = …) | Lock the index being modified. Source |
| ALTER INDEX … ATTACH PARTITION | From 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
- Manual source: explicit locking 753057e340da
- Table lock conflict definitions 753057e340da
- Row lock mode definitions 753057e340da
Source collection date: 2026-09-27.