文档首页
MySQL 8.4 参考手册
8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 64%

28.3.44 INFORMATION_SCHEMA TRIGGERS 表28.3.44 The INFORMATION_SCHEMA TRIGGERS Table

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 always def.

  • 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 is INSERT (a row was inserted), DELETE (a row was deleted), or UPDATE (a row was modified).

  • EVENT_OBJECT_CATALOG、EVENT_OBJECT_SCHEMA 和 EVENT_OBJECT_TABLEEVENT_OBJECT_CATALOG, EVENT_OBJECT_SCHEMA, and EVENT_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. The EVENT_OBJECT_CATALOG value is always def.

  • 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 same EVENT_MANIPULATION and ACTION_TIMING values.

  • ACTION_CONDITION

    该值始终为NULL。This value is always NULL.

  • 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 always ROW.

  • ACTION_TIMING

    触发器是在触发事件之前还是之后激活。该值为 BEFORE 或 AFTER。Whether the trigger activates before or after the triggering event. The value is BEFORE or AFTER.

  • ACTION_REFERENCE_OLD_TABLE

    该值始终为NULL。This value is always NULL.

  • ACTION_REFERENCE_NEW_TABLE

    该值始终为NULL。This value is always NULL.

  • ACTION_REFERENCE_OLD_ROW 和 ACTION_REFERENCE_NEW_ROWACTION_REFERENCE_OLD_ROW and ACTION_REFERENCE_NEW_ROW

    分别为旧列和新列的标识符。ACTION_REFERENCE_OLD_ROW 的值始终为 OLD,ACTION_REFERENCE_NEW_ROW 的值始终为 NEW。The old and new column identifiers, respectively. The ACTION_REFERENCE_OLD_ROW value is always OLD and the ACTION_REFERENCE_NEW_ROW value is always NEW.

  • CREATED

    触发器创建的日期和时间。对于触发器,这是一个 TIMESTAMP(2) 值(带有百分之一秒的小数部分)。The date and time when the trigger was created. This is a TIMESTAMP(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”.

  • DEFINERDEFINER

    DEFINER 子句中指定的账户名称(通常是创建触发器的用户),格式为 'user_name'@'host_name'。The account named in the DEFINER clause (often the user who created the trigger), in 'user_name'@'host_name' format.

  • CHARACTER_SET_CLIENT

    创建触发器时 character_set_client 系统变量的会话值。The session value of the character_set_client system variable when the trigger was created.

  • COLLATION_CONNECTION

    创建触发器时 collation_connection 系统变量的会话值。The session value of the collation_connection system 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.TRIGGERS
       WHERE 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”.