ACCESS EXCLUSIVE
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.
当前阅读 PG 18·选择有来源记录的版本
此版本暂无所选语言的定义,以下显示原始英文内容。
兼容性
比较不同事务持有同一对象的锁 表锁.
× 冲突模式
· 兼容模式
- 与该范围内所有模式冲突。
取得此锁模式的命令
| SQL 命令 | 对象、阶段与条件 |
|---|---|
| REFRESH MATERIALIZED VIEW (without CONCURRENTLY) | Lock the materialized view, blocking ordinary reads as well. 来源 |
| DROP TABLE | Lock the table being dropped. Dependencies and CASCADE can require additional locks. 来源 |
| DROP INDEX (without CONCURRENTLY) | Take ACCESS EXCLUSIVE on the parent table, blocking reads and writes; the index is locked too. 来源 |
| TRUNCATE | Lock each table being truncated. Options and dependencies determine the affected table set. 来源 |
| CLUSTER | Block concurrent reads and writes while rewriting the table. 来源 |
| VACUUM FULL | Block concurrent reads and writes while rewriting the table. 来源 |
| 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. 来源 |
| REINDEX (index being rebuilt) | Lock the index itself. Planning also accesses indexes, so ordinary REINDEX can still block queries. 来源 |
| LOCK TABLE … IN ACCESS EXCLUSIVE MODE | Request this table mode explicitly. Omitting IN MODE defaults to ACCESS EXCLUSIVE. 来源 |
| ALTER TABLE … ADD COLUMN | A rewrite depends on version and default expression. Avoiding the rewrite does not reduce the listed lock mode. 来源 |
| ALTER TABLE … DROP COLUMN | Drop a column and change the table definition. 来源 |
| ALTER TABLE … ALTER COLUMN … SET / DROP DEFAULT | Change the column default. 来源 |
| ALTER TABLE … ALTER COLUMN … TYPE | Change the column type. Whether a rewrite is needed does not change this lock requirement. 来源 |
| ALTER TABLE … ALTER COLUMN … SET STORAGE | Change the column storage strategy. 来源 |
| ALTER TABLE … ALTER COLUMN … SET COMPRESSION | Change the column compression method. 来源 |
| ALTER TABLE … SET TABLESPACE | Move the table to another tablespace. 来源 |
| ALTER TABLE … SET LOGGED / UNLOGGED | Change table persistence. 来源 |
| ALTER TABLE … SET ACCESS METHOD | Change the table access method. 来源 |
| ALTER TABLE … DROP CONSTRAINT | Drop the constraint and any dependent index as applicable. 来源 |
| ALTER TABLE … ALTER CONSTRAINT | Change constraint properties. 来源 |
| ALTER TABLE … ALTER COLUMN … SET NOT NULL | Set a not-null constraint. 来源 |
| ALTER TABLE … ALTER COLUMN … DROP NOT NULL | Drop a not-null constraint. 来源 |
| ALTER TABLE … ENABLE / DISABLE RULE | Enable or disable rules. 来源 |
| ALTER TABLE … ENABLE / DISABLE ROW LEVEL SECURITY | Enable or disable row-level security. 来源 |
| ALTER TABLE … FORCE / NO FORCE ROW LEVEL SECURITY | Change whether the table owner is subject to row-level security. 来源 |
| ALTER TABLE … ALTER COLUMN … DROP EXPRESSION | Drop a generated-column expression. 来源 |
| ALTER TABLE … ALTER COLUMN … SET EXPRESSION | Set a generated-column expression. 来源 |
| 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. 来源 |
| ALTER TABLE … ALTER COLUMN … ADD GENERATED … AS IDENTITY | Add identity properties to a column. 来源 |
| ALTER TABLE … ALTER COLUMN … DROP IDENTITY | Drop identity properties. 来源 |
| ALTER TABLE … INHERIT / NO INHERIT (child table) | This entry describes the altered child table; the inheritance parent is locked separately. 来源 |
| ALTER TABLE … OWNER TO | Change table ownership. 来源 |
| ALTER TABLE … REPLICA IDENTITY | Change replica identity. 来源 |
| ALTER TABLE … RENAME | Rename the table, column or constraint. 来源 |
| ALTER TABLE … ADD CONSTRAINT (CHECK / UNIQUE / PRIMARY KEY / EXCLUDE) | Ordinary constraint creation. Adding a foreign key instead uses SHARE ROW EXCLUSIVE. 来源 |
| 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. 来源 |
| 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. 来源 |
| ALTER TABLE … DETACH PARTITION (parent table) | Ordinary detach without CONCURRENTLY. 来源 |
| ALTER TABLE … DETACH PARTITION (partition being detached) | Ordinary detach takes ACCESS EXCLUSIVE on the partition being detached. 来源 |
| 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. 来源 |
| ALTER INDEX … SET TABLESPACE | Lock the index being moved, not the similarly named table. 来源 |
| ALTER INDEX … SET / RESET (fillfactor = …) | Lock the index being modified. 来源 |
| ALTER INDEX … ATTACH PARTITION | From PostgreSQL 11, modify the partitioned parent index and the child index being attached. 来源 |
其他锁模式
- conflicts
- access-share, row-share, row-exclusive, share-update-exclusive, share, share-row-exclusive, exclusive, access-exclusive
版本定义 PG 18
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.
比较版本
完整来源事实
commands
map[label:REFRESH MATERIALIZED VIEW (without CONCURRENTLY) note:Lock the materialized view, blocking ordinary reads as well. slug:refresh-materialized-view source:map[kind:documentation path:doc/src/sgml/mvcc.sgml revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:4b7bf77ee0af4b86052330ff2421d567df3604b75fe7d4f522bec84fdea87340 url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/doc/src/sgml/mvcc.sgml] source_url:https://www.postgresql.org/docs/18/explicit-locking.html variant:6d6f1c99adb4], map[label:DROP TABLE note:Lock the table being dropped. Dependencies and CASCADE can require additional locks. slug:drop-table source:map[kind:documentation path:doc/src/sgml/mvcc.sgml revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:4b7bf77ee0af4b86052330ff2421d567df3604b75fe7d4f522bec84fdea87340 url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/doc/src/sgml/mvcc.sgml] source_url:https://www.postgresql.org/docs/18/explicit-locking.html variant:a828f5eb8dde], map[label:DROP INDEX (without CONCURRENTLY) note:Take ACCESS EXCLUSIVE on the parent table, blocking reads and writes; the index is locked too. slug:drop-index source:map[kind:command-documentation path:doc/src/sgml/ref/reindex.sgml revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:5e889d6e1d9b09d5f9cd3f7086ca13f540da0fe8262cdd8a9037ce9aa6f1dfdf url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/doc/src/sgml/ref/reindex.sgml] source_url:https://www.postgresql.org/docs/18/sql-reindex.html variant:ceb1b7977563], map[label:TRUNCATE note:Lock each table being truncated. Options and dependencies determine the affected table set. slug:truncate source:map[kind:documentation path:doc/src/sgml/mvcc.sgml revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:4b7bf77ee0af4b86052330ff2421d567df3604b75fe7d4f522bec84fdea87340 url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/doc/src/sgml/mvcc.sgml] source_url:https://www.postgresql.org/docs/18/explicit-locking.html variant:e04c709b6168], map[label:CLUSTER note:Block concurrent reads and writes while rewriting the table. slug:cluster source:map[kind:documentation path:doc/src/sgml/mvcc.sgml revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:4b7bf77ee0af4b86052330ff2421d567df3604b75fe7d4f522bec84fdea87340 url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/doc/src/sgml/mvcc.sgml] source_url:https://www.postgresql.org/docs/18/explicit-locking.html variant:5bfe0a39463c], map[label:VACUUM FULL note:Block concurrent reads and writes while rewriting the table. slug:vacuum source:map[kind:documentation path:doc/src/sgml/mvcc.sgml revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:4b7bf77ee0af4b86052330ff2421d567df3604b75fe7d4f522bec84fdea87340 url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/doc/src/sgml/mvcc.sgml] source_url:https://www.postgresql.org/docs/18/explicit-locking.html variant:e13d8c96ffc2], map[label:VACUUM (tail truncation) note:Ordinary VACUUM briefly attempts ACCESS EXCLUSIVE when returning empty tail pages to the operating system. Where supported, disabling truncation avoids this phase. slug:vacuum source:map[kind:source path:src/backend/access/heap/vacuumlazy.c revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:90932e3b1a7b57dda8f740807def59aedb57fbd0e2173e3af3309f145192c7c2 url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/access/heap/vacuumlazy.c] source_url:https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/access/heap/vacuumlazy.c variant:2eebd3f45118], map[label:REINDEX (index being rebuilt) note:Lock the index itself. Planning also accesses indexes, so ordinary REINDEX can still block queries. slug:reindex source:map[kind:command-documentation path:doc/src/sgml/ref/reindex.sgml revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:5e889d6e1d9b09d5f9cd3f7086ca13f540da0fe8262cdd8a9037ce9aa6f1dfdf url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/doc/src/sgml/ref/reindex.sgml] source_url:https://www.postgresql.org/docs/18/sql-reindex.html variant:143d0bc28d7e], map[label:LOCK TABLE … IN ACCESS EXCLUSIVE MODE note:Request this table mode explicitly. Omitting IN MODE defaults to ACCESS EXCLUSIVE. slug:lock source:map[kind:documentation path:doc/src/sgml/mvcc.sgml revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:4b7bf77ee0af4b86052330ff2421d567df3604b75fe7d4f522bec84fdea87340 url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/doc/src/sgml/mvcc.sgml] source_url:https://www.postgresql.org/docs/18/explicit-locking.html variant:df83cd250695], map[label:ALTER TABLE … ADD COLUMN note:A rewrite depends on version and default expression. Avoiding the rewrite does not reduce the listed lock mode. slug:alter-table source:map[kind:source path:src/backend/commands/tablecmds.c revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:df8817816f893e73d5648fea169e222ba33320e5b24bf755b424b29098f4e7da url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c] source_url:https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c variant:101ed8a54290], map[label:ALTER TABLE … DROP COLUMN note:Drop a column and change the table definition. slug:alter-table source:map[kind:source path:src/backend/commands/tablecmds.c revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:df8817816f893e73d5648fea169e222ba33320e5b24bf755b424b29098f4e7da url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c] source_url:https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c variant:0fc76ebe1334], map[label:ALTER TABLE … ALTER COLUMN … SET / DROP DEFAULT note:Change the column default. slug:alter-table source:map[kind:source path:src/backend/commands/tablecmds.c revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:df8817816f893e73d5648fea169e222ba33320e5b24bf755b424b29098f4e7da url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c] source_url:https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c variant:1a94f9c5cd56], map[label:ALTER TABLE … ALTER COLUMN … TYPE note:Change the column type. Whether a rewrite is needed does not change this lock requirement. slug:alter-table source:map[kind:source path:src/backend/commands/tablecmds.c revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:df8817816f893e73d5648fea169e222ba33320e5b24bf755b424b29098f4e7da url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c] source_url:https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c variant:990cf70782de], map[label:ALTER TABLE … ALTER COLUMN … SET STORAGE note:Change the column storage strategy. slug:alter-table source:map[kind:source path:src/backend/commands/tablecmds.c revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:df8817816f893e73d5648fea169e222ba33320e5b24bf755b424b29098f4e7da url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c] source_url:https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c variant:9a7931327313], map[label:ALTER TABLE … ALTER COLUMN … SET COMPRESSION note:Change the column compression method. slug:alter-table source:map[kind:source path:src/backend/commands/tablecmds.c revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:df8817816f893e73d5648fea169e222ba33320e5b24bf755b424b29098f4e7da url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c] source_url:https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c variant:8e37203e0276], map[label:ALTER TABLE … SET TABLESPACE note:Move the table to another tablespace. slug:alter-table source:map[kind:source path:src/backend/commands/tablecmds.c revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:df8817816f893e73d5648fea169e222ba33320e5b24bf755b424b29098f4e7da url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c] source_url:https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c variant:e3b5e0ef38be], map[label:ALTER TABLE … SET LOGGED / UNLOGGED note:Change table persistence. slug:alter-table source:map[kind:source path:src/backend/commands/tablecmds.c revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:df8817816f893e73d5648fea169e222ba33320e5b24bf755b424b29098f4e7da url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c] source_url:https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c variant:fcc4aca97606], map[label:ALTER TABLE … SET ACCESS METHOD note:Change the table access method. slug:alter-table source:map[kind:source path:src/backend/commands/tablecmds.c revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:df8817816f893e73d5648fea169e222ba33320e5b24bf755b424b29098f4e7da url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c] source_url:https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c variant:262b3065bcd2], map[label:ALTER TABLE … DROP CONSTRAINT note:Drop the constraint and any dependent index as applicable. slug:alter-table source:map[kind:source path:src/backend/commands/tablecmds.c revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:df8817816f893e73d5648fea169e222ba33320e5b24bf755b424b29098f4e7da url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c] source_url:https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c variant:f60b1855cf54], map[label:ALTER TABLE … ALTER CONSTRAINT note:Change constraint properties. slug:alter-table source:map[kind:source path:src/backend/commands/tablecmds.c revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:df8817816f893e73d5648fea169e222ba33320e5b24bf755b424b29098f4e7da url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c] source_url:https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c variant:6573f5a4b501], map[label:ALTER TABLE … ALTER COLUMN … SET NOT NULL note:Set a not-null constraint. slug:alter-table source:map[kind:source path:src/backend/commands/tablecmds.c revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:df8817816f893e73d5648fea169e222ba33320e5b24bf755b424b29098f4e7da url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c] source_url:https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c variant:408f931a5716], map[label:ALTER TABLE … ALTER COLUMN … DROP NOT NULL note:Drop a not-null constraint. slug:alter-table source:map[kind:source path:src/backend/commands/tablecmds.c revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:df8817816f893e73d5648fea169e222ba33320e5b24bf755b424b29098f4e7da url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c] source_url:https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c variant:454adb52dbcf], map[label:ALTER TABLE … ENABLE / DISABLE RULE note:Enable or disable rules. slug:alter-table source:map[kind:source path:src/backend/commands/tablecmds.c revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:df8817816f893e73d5648fea169e222ba33320e5b24bf755b424b29098f4e7da url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c] source_url:https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c variant:e467e059ceca], map[label:ALTER TABLE … ENABLE / DISABLE ROW LEVEL SECURITY note:Enable or disable row-level security. slug:alter-table source:map[kind:source path:src/backend/commands/tablecmds.c revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:df8817816f893e73d5648fea169e222ba33320e5b24bf755b424b29098f4e7da url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c] source_url:https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c variant:68f6d32b3365], map[label:ALTER TABLE … FORCE / NO FORCE ROW LEVEL SECURITY note:Change whether the table owner is subject to row-level security. slug:alter-table source:map[kind:source path:src/backend/commands/tablecmds.c revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:df8817816f893e73d5648fea169e222ba33320e5b24bf755b424b29098f4e7da url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c] source_url:https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c variant:17c12a809f4d], map[label:ALTER TABLE … ALTER COLUMN … DROP EXPRESSION note:Drop a generated-column expression. slug:alter-table source:map[kind:source path:src/backend/commands/tablecmds.c revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:df8817816f893e73d5648fea169e222ba33320e5b24bf755b424b29098f4e7da url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c] source_url:https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c variant:dd4120e44205], map[label:ALTER TABLE … ALTER COLUMN … SET EXPRESSION note:Set a generated-column expression. slug:alter-table source:map[kind:source path:src/backend/commands/tablecmds.c revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:df8817816f893e73d5648fea169e222ba33320e5b24bf755b424b29098f4e7da url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c] source_url:https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c variant:f4c5618b7cfc], map[label:ALTER TABLE … ALTER COLUMN … SET GENERATED / RESTART / SET sequence_option note:Change identity-column properties or its implicit sequence options. This is not a standalone SET SEQUENCE subcommand. slug:alter-table source:map[kind:source path:src/backend/commands/tablecmds.c revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:df8817816f893e73d5648fea169e222ba33320e5b24bf755b424b29098f4e7da url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c] source_url:https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c variant:d8c841136f43], map[label:ALTER TABLE … ALTER COLUMN … ADD GENERATED … AS IDENTITY note:Add identity properties to a column. slug:alter-table source:map[kind:source path:src/backend/commands/tablecmds.c revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:df8817816f893e73d5648fea169e222ba33320e5b24bf755b424b29098f4e7da url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c] source_url:https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c variant:418c0d8ebe52], map[label:ALTER TABLE … ALTER COLUMN … DROP IDENTITY note:Drop identity properties. slug:alter-table source:map[kind:source path:src/backend/commands/tablecmds.c revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:df8817816f893e73d5648fea169e222ba33320e5b24bf755b424b29098f4e7da url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c] source_url:https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c variant:f3b143dbe043], map[label:ALTER TABLE … INHERIT / NO INHERIT (child table) note:This entry describes the altered child table; the inheritance parent is locked separately. slug:alter-table source:map[kind:source path:src/backend/commands/tablecmds.c revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:df8817816f893e73d5648fea169e222ba33320e5b24bf755b424b29098f4e7da url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c] source_url:https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c variant:008b39783d83], map[label:ALTER TABLE … OWNER TO note:Change table ownership. slug:alter-table source:map[kind:source path:src/backend/commands/tablecmds.c revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:df8817816f893e73d5648fea169e222ba33320e5b24bf755b424b29098f4e7da url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c] source_url:https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c variant:98d32b942790], map[label:ALTER TABLE … REPLICA IDENTITY note:Change replica identity. slug:alter-table source:map[kind:source path:src/backend/commands/tablecmds.c revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:df8817816f893e73d5648fea169e222ba33320e5b24bf755b424b29098f4e7da url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c] source_url:https://github.com/postgres/postgres/blob/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c variant:3cac4a375f89], map[label:ALTER TABLE … RENAME note:Rename the table, column or constraint. slug:alter-table source:map[kind:command-documentation path:doc/src/sgml/ref/alter_table.sgml revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:10436673fa2f093bdf51986a06d22dd748a9bb003bcd5517db2a65fba569a3c9 url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/doc/src/sgml/ref/alter_table.sgml] source_url:https://www.postgresql.org/docs/18/sql-altertable.html variant:f40830ffbc58], map[label:ALTER TABLE … ADD CONSTRAINT (CHECK / UNIQUE / PRIMARY KEY / EXCLUDE) note:Ordinary constraint creation. Adding a foreign key instead uses SHARE ROW EXCLUSIVE. slug:alter-table source:map[kind:command-documentation path:doc/src/sgml/ref/alter_table.sgml revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:10436673fa2f093bdf51986a06d22dd748a9bb003bcd5517db2a65fba569a3c9 url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/doc/src/sgml/ref/alter_table.sgml] source_url:https://www.postgresql.org/docs/18/sql-altertable.html variant:3b0faf718022], map[label:ALTER TABLE … ATTACH PARTITION (partition being attached) note:The table being attached requires ACCESS EXCLUSIVE. An appropriate CHECK constraint can avoid a validation scan but not this lock. slug:alter-table source:map[kind:command-documentation path:doc/src/sgml/ref/alter_table.sgml revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:10436673fa2f093bdf51986a06d22dd748a9bb003bcd5517db2a65fba569a3c9 url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/doc/src/sgml/ref/alter_table.sgml] source_url:https://www.postgresql.org/docs/18/sql-altertable.html variant:1483396e674a], map[label:ALTER TABLE … ATTACH PARTITION (default partition) note: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. slug:alter-table source:map[kind:command-documentation path:doc/src/sgml/ref/alter_table.sgml revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:10436673fa2f093bdf51986a06d22dd748a9bb003bcd5517db2a65fba569a3c9 url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/doc/src/sgml/ref/alter_table.sgml] source_url:https://www.postgresql.org/docs/18/sql-altertable.html variant:5311d5d4a151], map[label:ALTER TABLE … DETACH PARTITION (parent table) note:Ordinary detach without CONCURRENTLY. slug:alter-table source:map[kind:command-documentation path:doc/src/sgml/ref/alter_table.sgml revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:10436673fa2f093bdf51986a06d22dd748a9bb003bcd5517db2a65fba569a3c9 url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/doc/src/sgml/ref/alter_table.sgml] source_url:https://www.postgresql.org/docs/18/sql-altertable.html variant:c459b16c94e5], map[label:ALTER TABLE … DETACH PARTITION (partition being detached) note:Ordinary detach takes ACCESS EXCLUSIVE on the partition being detached. slug:alter-table source:map[kind:command-documentation path:doc/src/sgml/ref/alter_table.sgml revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:10436673fa2f093bdf51986a06d22dd748a9bb003bcd5517db2a65fba569a3c9 url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/doc/src/sgml/ref/alter_table.sgml] source_url:https://www.postgresql.org/docs/18/sql-altertable.html variant:c60a0ad36a6e], map[label:ALTER TABLE … DETACH PARTITION … CONCURRENTLY (partition, final phase) note:The second phase takes ACCESS EXCLUSIVE on the detached partition. CONCURRENTLY is not allowed when a default partition exists. slug:alter-table source:map[kind:command-documentation path:doc/src/sgml/ref/alter_table.sgml revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:10436673fa2f093bdf51986a06d22dd748a9bb003bcd5517db2a65fba569a3c9 url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/doc/src/sgml/ref/alter_table.sgml] source_url:https://www.postgresql.org/docs/18/sql-altertable.html variant:19f063dfde3e], map[label:ALTER INDEX … SET TABLESPACE note:Lock the index being moved, not the similarly named table. slug:alter-index source:map[kind:command-documentation path:doc/src/sgml/ref/alter_index.sgml revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:746cd43287186dfbfa6acf77fd5c6713e66919653fb00af5476a0baa65988e7a url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/doc/src/sgml/ref/alter_index.sgml] source_url:https://www.postgresql.org/docs/18/sql-alterindex.html variant:0960eb65e32b], map[label:ALTER INDEX … SET / RESET (fillfactor = …) note:Lock the index being modified. slug:alter-index source:map[kind:command-documentation path:doc/src/sgml/ref/alter_index.sgml revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:746cd43287186dfbfa6acf77fd5c6713e66919653fb00af5476a0baa65988e7a url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/doc/src/sgml/ref/alter_index.sgml] source_url:https://www.postgresql.org/docs/18/sql-alterindex.html variant:6c9c2fe652d7], map[label:ALTER INDEX … ATTACH PARTITION note:From PostgreSQL 11, modify the partitioned parent index and the child index being attached. slug:alter-index source:map[kind:command-documentation path:doc/src/sgml/ref/alter_index.sgml revision:753057e340da8f22e57c9a409ea7a235fd6a46bd sha256:746cd43287186dfbfa6acf77fd5c6713e66919653fb00af5476a0baa65988e7a url:https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/doc/src/sgml/ref/alter_index.sgml] source_url:https://www.postgresql.org/docs/18/sql-alterindex.html variant:a3b2d216f98b]
provenance
{"doc_slug":"18","fetched_at":"2026-09-27T09:39:42+00:00","label":"18","major":"18","official_url":"https://www.postgresql.org/docs/18/explicit-locking.html","ref":"REL_18_STABLE","revision":"753057e340da8f22e57c9a409ea7a235fd6a46bd","sources":[{"kind":"command-documentation","path":"doc/src/sgml/ref/alter_index.sgml","revision":"753057e340da8f22e57c9a409ea7a235fd6a46bd","sha256":"746cd43287186dfbfa6acf77fd5c6713e66919653fb00af5476a0baa65988e7a","url":"https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/doc/src/sgml/ref/alter_index.sgml"},{"kind":"command-documentation","path":"doc/src/sgml/ref/alter_table.sgml","revision":"753057e340da8f22e57c9a409ea7a235fd6a46bd","sha256":"10436673fa2f093bdf51986a06d22dd748a9bb003bcd5517db2a65fba569a3c9","url":"https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/doc/src/sgml/ref/alter_table.sgml"},{"kind":"command-documentation","path":"doc/src/sgml/ref/comment.sgml","revision":"753057e340da8f22e57c9a409ea7a235fd6a46bd","sha256":"d0048329d237192696d7ccb9471aba4137d943556fdb770e2ffb3cf6c511c18f","url":"https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/doc/src/sgml/ref/comment.sgml"},{"kind":"source","path":"src/backend/commands/copy.c","revision":"753057e340da8f22e57c9a409ea7a235fd6a46bd","sha256":"f50ecc1531109fc172d841d461e209cef611f3d017ef4184034c39e128deabbe","url":"https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/copy.c"},{"kind":"command-documentation","path":"doc/src/sgml/ref/create_index.sgml","revision":"753057e340da8f22e57c9a409ea7a235fd6a46bd","sha256":"3698f11c6f447d127e4624a1a845dee4d5146b8337ddc6d895a7962e676717f8","url":"https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/doc/src/sgml/ref/create_index.sgml"},{"kind":"source","path":"src/backend/access/heap/heapam.c","revision":"753057e340da8f22e57c9a409ea7a235fd6a46bd","sha256":"bca2ca0746a1862016bdb416b8482441a7b16360f71afe5e4abf6dbae0fa0c72","url":"https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/access/heap/heapam.c"},{"kind":"source","path":"src/backend/catalog/index.c","revision":"753057e340da8f22e57c9a409ea7a235fd6a46bd","sha256":"98a4156a5c21ae856a3b583b633cdeb578a5b69910386c9f166d69fcb04ba2d0","url":"https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/catalog/index.c"},{"kind":"command-documentation","path":"doc/src/sgml/ref/insert.sgml","revision":"753057e340da8f22e57c9a409ea7a235fd6a46bd","sha256":"f93403779fb1d980cd5995a1e2741bbdae8404584407610f9aba33ec4724a39f","url":"https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/doc/src/sgml/ref/insert.sgml"},{"kind":"source","path":"src/backend/storage/lmgr/lock.c","revision":"753057e340da8f22e57c9a409ea7a235fd6a46bd","sha256":"e7f43560bf6a8417ff46991238084b6edeb44a995b87670ed1f7fa6f1515276b","url":"https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/storage/lmgr/lock.c"},{"kind":"documentation","path":"doc/src/sgml/mvcc.sgml","revision":"753057e340da8f22e57c9a409ea7a235fd6a46bd","sha256":"4b7bf77ee0af4b86052330ff2421d567df3604b75fe7d4f522bec84fdea87340","url":"https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/doc/src/sgml/mvcc.sgml"},{"kind":"command-documentation","path":"doc/src/sgml/ref/reindex.sgml","revision":"753057e340da8f22e57c9a409ea7a235fd6a46bd","sha256":"5e889d6e1d9b09d5f9cd3f7086ca13f540da0fe8262cdd8a9037ce9aa6f1dfdf","url":"https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/doc/src/sgml/ref/reindex.sgml"},{"kind":"source","path":"src/backend/utils/adt/ri_triggers.c","revision":"753057e340da8f22e57c9a409ea7a235fd6a46bd","sha256":"a3fed49fbda88fe0fe5bcf35eb019fced28596ae4046233f2acb2eb9f90ab1da","url":"https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/utils/adt/ri_triggers.c"},{"kind":"source","path":"src/backend/commands/tablecmds.c","revision":"753057e340da8f22e57c9a409ea7a235fd6a46bd","sha256":"df8817816f893e73d5648fea169e222ba33320e5b24bf755b424b29098f4e7da","url":"https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/commands/tablecmds.c"},{"kind":"command-documentation","path":"doc/src/sgml/ref/vacuum.sgml","revision":"753057e340da8f22e57c9a409ea7a235fd6a46bd","sha256":"80ca5592cda7b74938385f84f09faac33574374c1a05d605a2d55982e4cf1bbf","url":"https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/doc/src/sgml/ref/vacuum.sgml"},{"kind":"source","path":"src/backend/access/heap/vacuumlazy.c","revision":"753057e340da8f22e57c9a409ea7a235fd6a46bd","sha256":"90932e3b1a7b57dda8f740807def59aedb57fbd0e2173e3af3309f145192c7c2","url":"https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/access/heap/vacuumlazy.c"}],"status":"stable"}summary
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.
来源引用
- https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/doc/src/sgml/mvcc.sgml
- https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/storage/lmgr/lock.c
- https://raw.githubusercontent.com/postgres/postgres/753057e340da8f22e57c9a409ea7a235fd6a46bd/src/backend/access/heap/heapam.c
定义来源
center · PostgreSQL 18 · 10:f4e8f137bfb08a664c8288824c1e36b5143ac875;11:170e416034ec0231d9e9238f2577eeb76ca8d181;12:3f302f0ed06f69c5ebd33d4df95895323a3cbef6;13:05f6c9ec2c475fae8fdd56ae40bd01afcf70d1f2;14:fba35c7c28a567839faba867db0808564c0a66db;15:0351991b8e7c7b64382e2f30ce581a8f276590a6;16:dcc37b7099a9f3cf2c75167d8dc92e75f96bc1fa;17:163288afd32a448244c8df75b3c33181aadd7f20;18:753057e340da8f22e57c9a409ea7a235fd6a46bd;19:b73d13c32c834a2c8e1c60cb92f79530376cedf1;20:2c10c2ce4d7bcd57543a49ab402af02a39724e0a
正文语言: en · 10:f4e8f137bfb08a664c8288824c1e36b5143ac875;11:170e416034ec0231d9e9238f2577eeb76ca8d181;12:3f302f0ed06f69c5ebd33d4df95895323a3cbef6;13:05f6c9ec2c475fae8fdd56ae40bd01afcf70d1f2;14:fba35c7c28a567839faba867db0808564c0a66db;15:0351991b8e7c7b64382e2f30ce581a8f276590a6;16:dcc37b7099a9f3cf2c75167d8dc92e75f96bc1fa;17:163288afd32a448244c8df75b3c33181aadd7f20;18:753057e340da8f22e57c9a409ea7a235fd6a46bd;19:b73d13c32c834a2c8e1c60cb92f79530376cedf1;20:2c10c2ce4d7bcd57543a49ab402af02a39724e0a