TRIGGERS 表提供有关触发器的信息。要查看表的触发器信息,您必须拥有该表的 TRIGGER 权限。The TRIGGERS table provides
information about triggers. To see information about a table's
triggers, you must have the TRIGGER
privilege for the table.
TRIGGERS 表具有以下列:The TRIGGERS table has these columns:
TRIGGER_CATALOG触发器所属的目录名称。该值始终为
def。The name of the catalog to which the trigger belongs. This value is alwaysdef.TRIGGER_SCHEMA触发器所属的模式(数据库)名称。The name of the schema (database) to which the trigger belongs.
TRIGGER_NAME触发器的名称。The name of the trigger.
EVENT_MANIPULATION触发事件。这是触发器激活时关联表上的操作类型。该值为
INSERT(插入了一行)、DELETE(删除了一行)或UPDATE(修改了一行)。The trigger event. This is the type of operation on the associated table for which the trigger activates. The value isINSERT(a row was inserted),DELETE(a row was deleted), orUPDATE(a row was modified).EVENT_OBJECT_CATALOG、EVENT_OBJECT_SCHEMA和EVENT_OBJECT_TABLEEVENT_OBJECT_CATALOG,EVENT_OBJECT_SCHEMA, andEVENT_OBJECT_TABLE如在第 27.3 节,“使用触发器”中所述,每个触发器都与恰好一个表相关。这些列分别指示该表所在的目录和模式(数据库),以及表名。
EVENT_OBJECT_CATALOG的值总是def。As noted in Section 27.3, “Using Triggers”, every trigger is associated with exactly one table. These columns indicate the catalog and schema (database) in which this table occurs, and the table name, respectively. TheEVENT_OBJECT_CATALOGvalue is alwaysdef.ACTION_ORDER触发器在具有相同
EVENT_MANIPULATION和ACTION_TIMING值的同一表上的触发器列表中的顺序位置。The ordinal position of the trigger's action within the list of triggers on the same table with the sameEVENT_MANIPULATIONandACTION_TIMINGvalues.ACTION_CONDITION该值始终为
NULL。This value is alwaysNULL.ACTION_STATEMENT触发器主体;即触发器激活时执行的语句。此文本使用 UTF-8 编码。The trigger body; that is, the statement executed when the trigger activates. This text uses UTF-8 encoding.
ACTION_ORIENTATION此值始终为
ROW。This value is alwaysROW.ACTION_TIMING触发器是在触发事件之前还是之后激活。该值为
BEFORE或AFTER。Whether the trigger activates before or after the triggering event. The value isBEFOREorAFTER.ACTION_REFERENCE_OLD_TABLE该值始终为
NULL。This value is alwaysNULL.ACTION_REFERENCE_NEW_TABLE该值始终为
NULL。This value is alwaysNULL.ACTION_REFERENCE_OLD_ROW和ACTION_REFERENCE_NEW_ROWACTION_REFERENCE_OLD_ROWandACTION_REFERENCE_NEW_ROW分别为旧列和新列的标识符。
ACTION_REFERENCE_OLD_ROW的值始终为OLD,ACTION_REFERENCE_NEW_ROW的值始终为NEW。The old and new column identifiers, respectively. TheACTION_REFERENCE_OLD_ROWvalue is alwaysOLDand theACTION_REFERENCE_NEW_ROWvalue is alwaysNEW.CREATED触发器创建的日期和时间。对于触发器,这是一个
TIMESTAMP(2)值(带有百分之一秒的小数部分)。The date and time when the trigger was created. This is aTIMESTAMP(2)value (with a fractional part in hundredths of seconds) for triggers.SQL_MODE创建触发器时生效的 SQL 模式,以及触发器执行时使用的 SQL 模式。有关允许值,请参见 第 7.1.11 节 “服务器 SQL 模式”。The SQL mode in effect when the trigger was created, and under which the trigger executes. For the permitted values, see Section 7.1.11, “Server SQL Modes”.
DEFINERDEFINERDEFINER子句中指定的账户名称(通常是创建触发器的用户),格式为'。The account named in theuser_name'@'host_name'DEFINERclause (often the user who created the trigger), in'format.user_name'@'host_name'CHARACTER_SET_CLIENT创建触发器时
character_set_client系统变量的会话值。The session value of thecharacter_set_clientsystem variable when the trigger was created.COLLATION_CONNECTION创建触发器时
collation_connection系统变量的会话值。The session value of thecollation_connectionsystem variable when the trigger was created.DATABASE_COLLATION与触发器相关联的数据库排序规则。The collation of the database with which the trigger is associated.
示例Example
下面的示例使用在 第 27.3 节,“使用触发器” 中定义的 ins_sum 触发器:The following example uses the ins_sum trigger
defined in Section 27.3, “Using Triggers”:
mysql>SELECT * FROM INFORMATION_SCHEMA.TRIGGERSWHERE TRIGGER_SCHEMA='test' AND TRIGGER_NAME='ins_sum'\G*************************** 1. row *************************** TRIGGER_CATALOG: def TRIGGER_SCHEMA: test TRIGGER_NAME: ins_sum EVENT_MANIPULATION: INSERT EVENT_OBJECT_CATALOG: def EVENT_OBJECT_SCHEMA: test EVENT_OBJECT_TABLE: account ACTION_ORDER: 1 ACTION_CONDITION: NULL ACTION_STATEMENT: SET @sum = @sum + NEW.amount ACTION_ORIENTATION: ROW ACTION_TIMING: BEFORE ACTION_REFERENCE_OLD_TABLE: NULL ACTION_REFERENCE_NEW_TABLE: NULL ACTION_REFERENCE_OLD_ROW: OLD ACTION_REFERENCE_NEW_ROW: NEW CREATED: 2018-08-08 10:10:12.61 SQL_MODE: ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES, NO_ZERO_IN_DATE,NO_ZERO_DATE, ERROR_FOR_DIVISION_BY_ZERO, NO_ENGINE_SUBSTITUTION DEFINER: me@localhost CHARACTER_SET_CLIENT: utf8mb4 COLLATION_CONNECTION: utf8mb4_0900_ai_ci DATABASE_COLLATION: utf8mb4_0900_ai_ci
触发器信息也可以通过 SHOW TRIGGERS 语句获得。参见 第 15.7.7.40 节,“SHOW TRIGGERS 语句”。Trigger information is also available from the
SHOW TRIGGERS statement. See
Section 15.7.7.40, “SHOW TRIGGERS Statement”.