↑↓ 选择↵ 打开⌫ 切换范围完整搜索

PG.CENTER 连接 PostgreSQL 文档、百科与生态知识。由 Pigsty 维护。

支持中的版本: 当前版本 (18) / 17 / 16 / 15 / 14
开发中的版本: 19 / 20devel
已结束支持的版本: 13 / 12 / 11 / 10 / 9.6 / 9.5 / 9.4 / 9.3 / 9.2 / 9.1 / 9.0 / 8.4 / 8.3 / 8.2 / 8.1 / 8.0 / 7.4 / 7.3 / 7.2
历史版本。 PostgreSQL 9.1 已结束支持。 2016-10-27. 请参阅 当前版本手册.

45.42. pg_trigger #

目录pg_trigger存储表和视图上的触发器。详见CREATE TRIGGER。

表 45.42. pg_trigger 列

NameTypeReferencesDescription
tgrelidoidpg_class.oidThe table this trigger is on
tgnamename Trigger name (must be unique among triggers of same table)
tgfoidoidpg_proc.oidThe function to be called
tgtypeint2 Bit mask identifying trigger firing conditions
tgenabledchar  Controls in which session_replication_role modes the trigger fires. O = trigger fires in “origin” and “local” modes, D = trigger is disabled, R = trigger fires in “replica” mode, A = trigger fires always.
tgisinternalbool True if trigger is internally generated (usually, to enforce the constraint identified by tgconstraint)
tgconstrrelidoidpg_class.oidThe table referenced by a referential integrity constraint
tgconstrindidoidpg_class.oidThe index supporting a unique, primary key, or referential integrity constraint
tgconstraintoidpg_constraint.oidThe pg_constraint entry associated with the trigger, if any
tgdeferrablebool True if constraint trigger is deferrable
tginitdeferredbool True if constraint trigger is initially deferred
tgnargsint2 Number of argument strings passed to trigger function
tgattrint2vectorpg_attribute.attnumColumn numbers, if trigger is column-specific; otherwise an empty array
tgargsbytea Argument strings to pass to trigger, each NULL-terminated
tgqualpg_node_tree Expression tree (in nodeToString() representation) for the trigger's WHEN condition, or null if none

当前,列限定触发器只支持UPDATE事件,因此tgattr只用于这种事件类型。tgtype也可以包含用于其他事件类型的位,但那些事件类型对应的是表级触发器,并且会忽略tgattr。

注意

当tgconstraint非零时,tgconstrrelid、tgconstrindid、tgdeferrable和tginitdeferred与被引用的pg_constraint 项有很大的冗余。但是,存在将一个不可延迟触发器关联到一个可延迟约束的可能性:外键约束可以有一些可延迟和一些不可延迟触发器。

注意

如果一个关系在本目录中拥有任何触发器,其pg_class.relhastriggers必须为真。

报告文档问题

阅读 上游文档. 反馈更正前请先核对 当前版本手册.