首页  >  文章  >  数据库  >  我们如何获取触发器的元数据?

我们如何获取触发器的元数据?

王林
王林转载
2023-08-30 22:45:02581浏览

我们如何获取触发器的元数据?

这可以借助 INFORMATION_SCHEMA 数据库来完成。以下语句将为我们提供触发器的元数据 -

mysql> Select trigger_schema, trigger_name, action_statement
    -> from information_schema.triggers\G
*************************** 1. row ***************************
  trigger_schema: query
    trigger_name: trigger_before_delete_sample
action_statement: BEGIN
SET @count = if (@count IS NULL, 1, (@count+1));
INSERT INTO sample_rowaffected values (@count);
END
*************************** 2. row ***************************
  trigger_schema: query
    trigger_name: before_inser_studentage
action_statement: IF NEW.age < 0 THEN SET NEW.age = 0;
END IF
*************************** 3. row ***************************
  trigger_schema: sys
    trigger_name: sys_config_insert_set_user
action_statement: BEGIN IF @sys.ignore_sys_config_triggers != true AND
NEW.set_by IS NULL THEN SET NEW.set_by = USER(); END IF; END
*************************** 5. row ***************************
  trigger_schema: sys
    trigger_name: sys_config_update_set_user
action_statement: BEGIN IF @sys.ignore_sys_config_triggers != true AND
NEW.set_by IS NULL THEN SET NEW.set_by = USER(); END IF; END
4 rows in set (0.03 sec)

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

声明:
本文转载于:tutorialspoint.com。如有侵权,请联系admin@php.cn删除