pg_trigger 是一个 系统目录 表,用于存储触发器信息。
pg_trigger 在 PostgreSQL 6.2 中添加。
按 PostgreSQL 版本定义
pg_trigger (PostgreSQL 19)
Table "pg_catalog.pg_trigger"
Column | Type | Collation | Nullable | Default
----------------+--------------+-----------+----------+---------
oid | oid | | not null |
tgrelid | oid | | not null |
tgparentid | oid | | not null |
tgname | name | | not null |
tgfoid | oid | | not null |
tgtype | smallint | | not null |
tgenabled | "char" | | not null |
tgisinternal | boolean | | not null |
tgconstrrelid | oid | | not null |
tgconstrindid | oid | | not null |
tgconstraint | oid | | not null |
tgdeferrable | boolean | | not null |
tginitdeferred | boolean | | not null |
tgnargs | smallint | | not null |
tgattr | int2vector | | not null |
tgargs | bytea | | not null |
tgqual | pg_node_tree | C | |
tgoldtable | name | | |
tgnewtable | name | | |
Indexes:
"pg_trigger_oid_index" PRIMARY KEY, btree (oid)
"pg_trigger_tgconstraint_index" btree (tgconstraint)
"pg_trigger_tgrelid_tgname_index" UNIQUE CONSTRAINT, btree (tgrelid, tgname)
文档: pg_trigger
pg_trigger (PostgreSQL 18)
Table "pg_catalog.pg_trigger"
Column | Type | Collation | Nullable | Default
----------------+--------------+-----------+----------+---------
oid | oid | | not null |
tgrelid | oid | | not null |
tgparentid | oid | | not null |
tgname | name | | not null |
tgfoid | oid | | not null |
tgtype | smallint | | not null |
tgenabled | "char" | | not null |
tgisinternal | boolean | | not null |
tgconstrrelid | oid | | not null |
tgconstrindid | oid | | not null |
tgconstraint | oid | | not null |
tgdeferrable | boolean | | not null |
tginitdeferred | boolean | | not null |
tgnargs | smallint | | not null |
tgattr | int2vector | | not null |
tgargs | bytea | | not null |
tgqual | pg_node_tree | C | |
tgoldtable | name | | |
tgnewtable | name | | |
Indexes:
"pg_trigger_oid_index" PRIMARY KEY, btree (oid)
"pg_trigger_tgconstraint_index" btree (tgconstraint)
"pg_trigger_tgrelid_tgname_index" UNIQUE CONSTRAINT, btree (tgrelid, tgname)
文档: pg_trigger
pg_trigger (PostgreSQL 17)
Table "pg_catalog.pg_trigger"
Column | Type | Collation | Nullable | Default
----------------+--------------+-----------+----------+---------
oid | oid | | not null |
tgrelid | oid | | not null |
tgparentid | oid | | not null |
tgname | name | | not null |
tgfoid | oid | | not null |
tgtype | smallint | | not null |
tgenabled | "char" | | not null |
tgisinternal | boolean | | not null |
tgconstrrelid | oid | | not null |
tgconstrindid | oid | | not null |
tgconstraint | oid | | not null |
tgdeferrable | boolean | | not null |
tginitdeferred | boolean | | not null |
tgnargs | smallint | | not null |
tgattr | int2vector | | not null |
tgargs | bytea | | not null |
tgqual | pg_node_tree | C | |
tgoldtable | name | | |
tgnewtable | name | | |
Indexes:
"pg_trigger_oid_index" PRIMARY KEY, btree (oid)
"pg_trigger_tgconstraint_index" btree (tgconstraint)
"pg_trigger_tgrelid_tgname_index" UNIQUE CONSTRAINT, btree (tgrelid, tgname)
文档: pg_trigger
pg_trigger (PostgreSQL 16)
Table "pg_catalog.pg_trigger"
Column | Type | Collation | Nullable | Default
----------------+--------------+-----------+----------+---------
oid | oid | | not null |
tgrelid | oid | | not null |
tgparentid | oid | | not null |
tgname | name | | not null |
tgfoid | oid | | not null |
tgtype | smallint | | not null |
tgenabled | "char" | | not null |
tgisinternal | boolean | | not null |
tgconstrrelid | oid | | not null |
tgconstrindid | oid | | not null |
tgconstraint | oid | | not null |
tgdeferrable | boolean | | not null |
tginitdeferred | boolean | | not null |
tgnargs | smallint | | not null |
tgattr | int2vector | | not null |
tgargs | bytea | | not null |
tgqual | pg_node_tree | C | |
tgoldtable | name | | |
tgnewtable | name | | |
Indexes:
"pg_trigger_oid_index" PRIMARY KEY, btree (oid)
"pg_trigger_tgconstraint_index" btree (tgconstraint)
"pg_trigger_tgrelid_tgname_index" UNIQUE CONSTRAINT, btree (tgrelid, tgname)
文档: pg_trigger
pg_trigger (PostgreSQL 15)
Table "pg_catalog.pg_trigger"
Column | Type | Collation | Nullable | Default
----------------+--------------+-----------+----------+---------
oid | oid | | not null |
tgrelid | oid | | not null |
tgparentid | oid | | not null |
tgname | name | | not null |
tgfoid | oid | | not null |
tgtype | smallint | | not null |
tgenabled | "char" | | not null |
tgisinternal | boolean | | not null |
tgconstrrelid | oid | | not null |
tgconstrindid | oid | | not null |
tgconstraint | oid | | not null |
tgdeferrable | boolean | | not null |
tginitdeferred | boolean | | not null |
tgnargs | smallint | | not null |
tgattr | int2vector | | not null |
tgargs | bytea | | not null |
tgqual | pg_node_tree | C | |
tgoldtable | name | | |
tgnewtable | name | | |
Indexes:
"pg_trigger_oid_index" PRIMARY KEY, btree (oid)
"pg_trigger_tgconstraint_index" btree (tgconstraint)
"pg_trigger_tgrelid_tgname_index" UNIQUE CONSTRAINT, btree (tgrelid, tgname)
文档: pg_trigger
pg_trigger (PostgreSQL 14)
Table "pg_catalog.pg_trigger"
Column | Type | Collation | Nullable | Default
----------------+--------------+-----------+----------+---------
oid | oid | | not null |
tgrelid | oid | | not null |
tgparentid | oid | | not null |
tgname | name | | not null |
tgfoid | oid | | not null |
tgtype | smallint | | not null |
tgenabled | "char" | | not null |
tgisinternal | boolean | | not null |
tgconstrrelid | oid | | not null |
tgconstrindid | oid | | not null |
tgconstraint | oid | | not null |
tgdeferrable | boolean | | not null |
tginitdeferred | boolean | | not null |
tgnargs | smallint | | not null |
tgattr | int2vector | | not null |
tgargs | bytea | | not null |
tgqual | pg_node_tree | C | |
tgoldtable | name | | |
tgnewtable | name | | |
Indexes:
"pg_trigger_oid_index" PRIMARY KEY, btree (oid)
"pg_trigger_tgconstraint_index" btree (tgconstraint)
"pg_trigger_tgrelid_tgname_index" UNIQUE CONSTRAINT, btree (tgrelid, tgname)
文档: pg_trigger
pg_trigger (PostgreSQL 13)
Table "pg_catalog.pg_trigger"
Column | Type | Collation | Nullable | Default
----------------+--------------+-----------+----------+---------
oid | oid | | not null |
tgrelid | oid | | not null |
tgparentid | oid | | not null |
tgname | name | | not null |
tgfoid | oid | | not null |
tgtype | smallint | | not null |
tgenabled | "char" | | not null |
tgisinternal | boolean | | not null |
tgconstrrelid | oid | | not null |
tgconstrindid | oid | | not null |
tgconstraint | oid | | not null |
tgdeferrable | boolean | | not null |
tginitdeferred | boolean | | not null |
tgnargs | smallint | | not null |
tgattr | int2vector | | not null |
tgargs | bytea | | not null |
tgqual | pg_node_tree | C | |
tgoldtable | name | | |
tgnewtable | name | | |
Indexes:
"pg_trigger_oid_index" UNIQUE, btree (oid)
"pg_trigger_tgconstraint_index" btree (tgconstraint)
"pg_trigger_tgrelid_tgname_index" UNIQUE, btree (tgrelid, tgname)
文档: pg_trigger
pg_trigger (PostgreSQL 12)
Table "pg_catalog.pg_trigger"
Column | Type | Collation | Nullable | Default
----------------+--------------+-----------+----------+---------
oid | oid | | not null |
tgrelid | oid | | not null |
tgname | name | | not null |
tgfoid | oid | | not null |
tgtype | smallint | | not null |
tgenabled | "char" | | not null |
tgisinternal | boolean | | not null |
tgconstrrelid | oid | | not null |
tgconstrindid | oid | | not null |
tgconstraint | oid | | not null |
tgdeferrable | boolean | | not null |
tginitdeferred | boolean | | not null |
tgnargs | smallint | | not null |
tgattr | int2vector | | not null |
tgargs | bytea | | not null |
tgqual | pg_node_tree | C | |
tgoldtable | name | | |
tgnewtable | name | | |
Indexes:
"pg_trigger_oid_index" UNIQUE, btree (oid)
"pg_trigger_tgrelid_tgname_index" UNIQUE, btree (tgrelid, tgname)
"pg_trigger_tgconstraint_index" btree (tgconstraint)
文档: pg_trigger
pg_trigger (PostgreSQL 11)
Table "pg_catalog.pg_trigger"
Column | Type | Collation | Nullable | Default
----------------+--------------+-----------+----------+---------
tgrelid | oid | | not null |
tgname | name | | not null |
tgfoid | oid | | not null |
tgtype | smallint | | not null |
tgenabled | "char" | | not null |
tgisinternal | boolean | | not null |
tgconstrrelid | oid | | not null |
tgconstrindid | oid | | not null |
tgconstraint | oid | | not null |
tgdeferrable | boolean | | not null |
tginitdeferred | boolean | | not null |
tgnargs | smallint | | not null |
tgattr | int2vector | | not null |
tgargs | bytea | | not null |
tgqual | pg_node_tree | | |
tgoldtable | name | | |
tgnewtable | name | | |
Indexes:
"pg_trigger_oid_index" UNIQUE, btree (oid)
"pg_trigger_tgrelid_tgname_index" UNIQUE, btree (tgrelid, tgname)
"pg_trigger_tgconstraint_index" btree (tgconstraint)
文档: pg_trigger
pg_trigger (PostgreSQL 10)
Table "pg_catalog.pg_trigger"
Column | Type | Collation | Nullable | Default
----------------+--------------+-----------+----------+---------
tgrelid | oid | | not null |
tgname | name | | not null |
tgfoid | oid | | not null |
tgtype | smallint | | not null |
tgenabled | "char" | | not null |
tgisinternal | boolean | | not null |
tgconstrrelid | oid | | not null |
tgconstrindid | oid | | not null |
tgconstraint | oid | | not null |
tgdeferrable | boolean | | not null |
tginitdeferred | boolean | | not null |
tgnargs | smallint | | not null |
tgattr | int2vector | | not null |
tgargs | bytea | | not null |
tgqual | pg_node_tree | | |
tgoldtable | name | | |
tgnewtable | name | | |
Indexes:
"pg_trigger_oid_index" UNIQUE, btree (oid)
"pg_trigger_tgrelid_tgname_index" UNIQUE, btree (tgrelid, tgname)
"pg_trigger_tgconstraint_index" btree (tgconstraint)
文档: pg_trigger
pg_trigger (PostgreSQL 9.6)
Table "pg_catalog.pg_trigger"
Column | Type | Modifiers
----------------+--------------+-----------
tgrelid | oid | not null
tgname | name | not null
tgfoid | oid | not null
tgtype | smallint | not null
tgenabled | "char" | not null
tgisinternal | boolean | not null
tgconstrrelid | oid | not null
tgconstrindid | oid | not null
tgconstraint | oid | not null
tgdeferrable | boolean | not null
tginitdeferred | boolean | not null
tgnargs | smallint | not null
tgattr | int2vector | not null
tgargs | bytea | not null
tgqual | pg_node_tree |
Indexes:
"pg_trigger_oid_index" UNIQUE, btree (oid)
"pg_trigger_tgrelid_tgname_index" UNIQUE, btree (tgrelid, tgname)
"pg_trigger_tgconstraint_index" btree (tgconstraint)
文档: pg_trigger
pg_trigger (PostgreSQL 9.5)
Table "pg_catalog.pg_trigger"
Column | Type | Modifiers
----------------+--------------+-----------
tgrelid | oid | not null
tgname | name | not null
tgfoid | oid | not null
tgtype | smallint | not null
tgenabled | "char" | not null
tgisinternal | boolean | not null
tgconstrrelid | oid | not null
tgconstrindid | oid | not null
tgconstraint | oid | not null
tgdeferrable | boolean | not null
tginitdeferred | boolean | not null
tgnargs | smallint | not null
tgattr | int2vector | not null
tgargs | bytea | not null
tgqual | pg_node_tree |
Indexes:
"pg_trigger_oid_index" UNIQUE, btree (oid)
"pg_trigger_tgrelid_tgname_index" UNIQUE, btree (tgrelid, tgname)
"pg_trigger_tgconstraint_index" btree (tgconstraint)
文档: pg_trigger
pg_trigger (PostgreSQL 9.4)
Table "pg_catalog.pg_trigger"
Column | Type | Modifiers
----------------+--------------+-----------
tgrelid | oid | not null
tgname | name | not null
tgfoid | oid | not null
tgtype | smallint | not null
tgenabled | "char" | not null
tgisinternal | boolean | not null
tgconstrrelid | oid | not null
tgconstrindid | oid | not null
tgconstraint | oid | not null
tgdeferrable | boolean | not null
tginitdeferred | boolean | not null
tgnargs | smallint | not null
tgattr | int2vector | not null
tgargs | bytea |
tgqual | pg_node_tree |
Indexes:
"pg_trigger_oid_index" UNIQUE, btree (oid)
"pg_trigger_tgrelid_tgname_index" UNIQUE, btree (tgrelid, tgname)
"pg_trigger_tgconstraint_index" btree (tgconstraint)
文档: pg_trigger
pg_trigger (PostgreSQL 9.3)
Table "pg_catalog.pg_trigger"
Column | Type | Modifiers
----------------+--------------+-----------
tgrelid | oid | not null
tgname | name | not null
tgfoid | oid | not null
tgtype | smallint | not null
tgenabled | "char" | not null
tgisinternal | boolean | not null
tgconstrrelid | oid | not null
tgconstrindid | oid | not null
tgconstraint | oid | not null
tgdeferrable | boolean | not null
tginitdeferred | boolean | not null
tgnargs | smallint | not null
tgattr | int2vector | not null
tgargs | bytea |
tgqual | pg_node_tree |
Indexes:
"pg_trigger_oid_index" UNIQUE, btree (oid)
"pg_trigger_tgrelid_tgname_index" UNIQUE, btree (tgrelid, tgname)
"pg_trigger_tgconstraint_index" btree (tgconstraint)
文档: pg_trigger
pg_trigger (PostgreSQL 9.2)
Table "pg_catalog.pg_trigger"
Column | Type | Modifiers
----------------+--------------+-----------
tgrelid | oid | not null
tgname | name | not null
tgfoid | oid | not null
tgtype | smallint | not null
tgenabled | "char" | not null
tgisinternal | boolean | not null
tgconstrrelid | oid | not null
tgconstrindid | oid | not null
tgconstraint | oid | not null
tgdeferrable | boolean | not null
tginitdeferred | boolean | not null
tgnargs | smallint | not null
tgattr | int2vector | not null
tgargs | bytea |
tgqual | pg_node_tree |
Indexes:
"pg_trigger_oid_index" UNIQUE, btree (oid)
"pg_trigger_tgrelid_tgname_index" UNIQUE, btree (tgrelid, tgname)
"pg_trigger_tgconstraint_index" btree (tgconstraint)
文档: pg_trigger
pg_trigger (PostgreSQL 9.1)
Table "pg_catalog.pg_trigger"
Column | Type | Modifiers
----------------+--------------+-----------
tgrelid | oid | not null
tgname | name | not null
tgfoid | oid | not null
tgtype | smallint | not null
tgenabled | "char" | not null
tgisinternal | boolean | not null
tgconstrrelid | oid | not null
tgconstrindid | oid | not null
tgconstraint | oid | not null
tgdeferrable | boolean | not null
tginitdeferred | boolean | not null
tgnargs | smallint | not null
tgattr | int2vector | not null
tgargs | bytea |
tgqual | pg_node_tree |
Indexes:
"pg_trigger_oid_index" UNIQUE, btree (oid)
"pg_trigger_tgrelid_tgname_index" UNIQUE, btree (tgrelid, tgname)
"pg_trigger_tgconstraint_index" btree (tgconstraint)
文档: pg_trigger
pg_trigger (PostgreSQL 9.0)
Table "pg_catalog.pg_trigger"
Column | Type | Modifiers
----------------+------------+-----------
tgrelid | oid | not null
tgname | name | not null
tgfoid | oid | not null
tgtype | smallint | not null
tgenabled | "char" | not null
tgisinternal | boolean | not null
tgconstrrelid | oid | not null
tgconstrindid | oid | not null
tgconstraint | oid | not null
tgdeferrable | boolean | not null
tginitdeferred | boolean | not null
tgnargs | smallint | not null
tgattr | int2vector | not null
tgargs | bytea |
tgqual | text |
Indexes:
"pg_trigger_oid_index" UNIQUE, btree (oid)
"pg_trigger_tgrelid_tgname_index" UNIQUE, btree (tgrelid, tgname)
"pg_trigger_tgconstraint_index" btree (tgconstraint)
文档: pg_trigger
pg_trigger (PostgreSQL 8.4)
Table "pg_catalog.pg_trigger"
Column | Type | Modifiers
----------------+------------+-----------
tgrelid | oid | not null
tgname | name | not null
tgfoid | oid | not null
tgtype | smallint | not null
tgenabled | "char" | not null
tgisconstraint | boolean | not null
tgconstrname | name | not null
tgconstrrelid | oid | not null
tgconstraint | oid | not null
tgdeferrable | boolean | not null
tginitdeferred | boolean | not null
tgnargs | smallint | not null
tgattr | int2vector | not null
tgargs | bytea |
Indexes:
"pg_trigger_oid_index" UNIQUE, btree (oid)
"pg_trigger_tgrelid_tgname_index" UNIQUE, btree (tgrelid, tgname)
"pg_trigger_tgconstrname_index" btree (tgconstrname)
文档: pg_trigger
pg_trigger (PostgreSQL 8.3)
Table "pg_catalog.pg_trigger"
Column | Type | Modifiers
----------------+------------+-----------
tgrelid | oid | not null
tgname | name | not null
tgfoid | oid | not null
tgtype | smallint | not null
tgenabled | "char" | not null
tgisconstraint | boolean | not null
tgconstrname | name | not null
tgconstrrelid | oid | not null
tgconstraint | oid | not null
tgdeferrable | boolean | not null
tginitdeferred | boolean | not null
tgnargs | smallint | not null
tgattr | int2vector | not null
tgargs | bytea |
Indexes:
"pg_trigger_oid_index" UNIQUE, btree (oid)
"pg_trigger_tgrelid_tgname_index" UNIQUE, btree (tgrelid, tgname)
"pg_trigger_tgconstrname_index" btree (tgconstrname)
文档: pg_trigger
pg_trigger (PostgreSQL 8.2)
Table "pg_catalog.pg_trigger"
Column | Type | Modifiers
----------------+------------+-----------
tgrelid | oid | not null
tgname | name | not null
tgfoid | oid | not null
tgtype | smallint | not null
tgenabled | boolean | not null
tgisconstraint | boolean | not null
tgconstrname | name | not null
tgconstrrelid | oid | not null
tgdeferrable | boolean | not null
tginitdeferred | boolean | not null
tgnargs | smallint | not null
tgattr | int2vector | not null
tgargs | bytea |
Indexes:
"pg_trigger_oid_index" UNIQUE, btree (oid)
"pg_trigger_tgrelid_tgname_index" UNIQUE, btree (tgrelid, tgname)
"pg_trigger_tgconstrname_index" btree (tgconstrname)
"pg_trigger_tgconstrrelid_index" btree (tgconstrrelid)
文档: pg_trigger
变更历史
- PostgreSQL 13
- 添加了列
tgparentid(commit b9b408c4)
- 添加了列
- PostgreSQL 10
- 添加了列
tgoldtable和tgnewtable(commit 8c48375e)
- 添加了列
- PostgreSQL 9.5
- 列
tgargs设置为NOT NULL(commit 82a532b3)
- 列
- PostgreSQL 9.1
- 列
tgqual的类型从TEXT更改为pg_node_tree(commit 303696c3)
- 列
- PostgreSQL 9.0
- PostgreSQL 8.3
- PostgreSQL 7.3
- 同一表中的触发器之间,列
tgname必须是唯一的 (commit 未知)
- 同一表中的触发器之间,列
- PostgreSQL 6.2
- 已添加 (commit 2d7b93c0)
参考资料
- PostgreSQL 文档: pg_trigger
