mysql查询触发器语句

发布时间: 2023-11-21 11:56 阅读: 文章来源:1MUMB2537PS
一、概述

下面分享几个查询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 hereorder by trigger_schema, trigger_name;

说明:

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

2.2 存储过程select routine_schema as database_name,routine_name,routine_type as type,data_type as return_type,routine_definition as definitionfrom information_schema.routineswhere routine_schema not in (‘sys‘, ‘information_schema‘, ‘mysql‘, ‘performance_schema‘)-- and r.routine_schema = ‘database_name‘ -- put your database name hereorder by routine_schema, routine_name;

说明:

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

小结

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

•••展开全文