首页 > 数据库 > mysql教程 > 我们如何使用 INFORMATION_SCHEMA 来获取特定数据库中触发器的详细信息?

我们如何使用 INFORMATION_SCHEMA 来获取特定数据库中触发器的详细信息?

王林
发布: 2023-09-08 19:17:02
转载
558 人浏览过

我们如何使用 INFORMATION_SCHEMA 来获取特定数据库中触发器的详细信息?

可以借助以下语句来完成 -

mysql> select * from information_schema.triggers where
    -> information_schema.triggers.trigger_schema like '%query%'\G
*************************** 1. row ***************************
            TRIGGER_CATALOG: def
             TRIGGER_SCHEMA: query
               TRIGGER_NAME: trigger_before_delete_sample
         EVENT_MANIPULATION: DELETE
       EVENT_OBJECT_CATALOG: def
        EVENT_OBJECT_SCHEMA: query
         EVENT_OBJECT_TABLE: sample
               ACTION_ORDER: 1
           ACTION_CONDITION: NULL
           ACTION_STATEMENT: BEGIN
SET @count = if (@count IS NULL, 1, (@count+1));
INSERT INTO sample_rowaffected values (@count);
END
         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: 2017-11-21 12:31:58.70
                   SQL_MODE: ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
                    DEFINER: root@localhost
       CHARACTER_SET_CLIENT: cp850
       COLLATION_CONNECTION: cp850_general_ci
         DATABASE_COLLATION: latin1_swedish_ci
*************************** 2. row ***************************
           TRIGGER_CATALOG: def
            TRIGGER_SCHEMA: query
              TRIGGER_NAME: before_inser_studentage
        EVENT_MANIPULATION: INSERT
      EVENT_OBJECT_CATALOG: def
       EVENT_OBJECT_SCHEMA: query
        EVENT_OBJECT_TABLE: student_age
              ACTION_ORDER: 1
          ACTION_CONDITION: NULL
          ACTION_STATEMENT: IF NEW.age < 0 THEN SET NEW.age = 0;
END IF
        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: 2017-11-21 11:26:15.34
                  SQL_MODE: ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
                   DEFINER: root@localhost
      CHARACTER_SET_CLIENT: cp850
      COLLATION_CONNECTION: cp850_general_ci
        DATABASE_COLLATION: latin1_swedish_ci

2 rows in set (0.03 sec)
登录后复制

以上是我们如何使用 INFORMATION_SCHEMA 来获取特定数据库中触发器的详细信息?的详细内容。更多信息请关注PHP中文网其他相关文章!

来源:tutorialspoint.com
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板