mysql触发器实战教程(DBA技术分享十-)

一、概述

下面分享几个查询mysql存储过程和触发器的语句

二、相关语句2.1 触发器
  • 列出 MySQL 数据库中的触发器

select trigger_schema as trigger_database, trigger_name, concat(event_object_schema, '.', event_object_table) as trigger_table, action_order, action_timing, event_manipulation as trigger_event, action_statement as 'definition' from information_schema.triggers where trigger_schema not in ('sys','mysql') -- and trigger_schema = 'database_name' -- put your database name here order by trigger_schema, trigger_name;

说明:

  • trigger_database - 触发器所在的数据库的名称
  • trigger_name - 触发器的名称
  • action_order - 触发器操作在同一张表上具有相同 trigger_event 和 action_timing 的触发器列表中的序号位置
  • action_timing - 触发激活时间:before、after
  • trigger_event - 具体的 SQL 操作:insert、update、delete
  • trigger_table - 带有数据库(模式)名称的触发器表的名称
  • 定义- 触发器的 SQL定义

mysql触发器实战教程(DBA技术分享十-)(1)

2.2 存储过程

select routine_schema as database_name, routine_name, routine_type as type, data_type as return_type, routine_definition as definition from information_schema.routines where routine_schema not in ('sys', 'information_schema', 'mysql', 'performance_schema') -- and r.routine_schema = 'database_name' -- put your database name here order by routine_schema, routine_name;

说明:

  • database_name - 数据库的名称(模式)
  • routine_name - 函数/过程的名称
  • 类型-程序功能
  • return_type - 对于存储函数,返回值数据类型,否则此值为空
  • 定义- 函数/过程执行的 SQL 语句的文本

mysql触发器实战教程(DBA技术分享十-)(2)

小结

后面会分享更多Linux和DBA方面内容,感兴趣的朋友可以关注下!

mysql触发器实战教程(DBA技术分享十-)(3)

,

免责声明:本文仅代表文章作者的个人观点,与本站无关。其原创性、真实性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容文字的真实性、完整性和原创性本站不作任何保证或承诺,请读者仅作参考,并自行核实相关内容。文章投诉邮箱:anhduc.ph@yahoo.com

    分享
    投诉
    首页