你如何列出 MySQL 数据库中的所有触发器?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47363/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 11:58:43  来源:igfitidea点击:

How do you list all triggers in a MySQL database?

mysqltriggers

提问by Harry

What is the command to list all triggers in a MySQL database?

列出 MySQL 数据库中所有触发器的命令是什么?

回答by Harry

The command for listing all triggers is:

列出所有触发器的命令是:

show triggers;

or you can access the INFORMATION_SCHEMAtable directly by:

或者您可以通过以下方式INFORMATION_SCHEMA直接访问该表:

select trigger_schema, trigger_name, action_statement
from information_schema.triggers

回答by Pragnesh Karia

I hope following code will give you more information.

我希望下面的代码能给你更多的信息。

select * from information_schema.triggers where 
information_schema.triggers.trigger_schema like '%your_db_name%'

This will give you total 22 Columns in MySQL version: 5.5.27and Above

这将在MySQL 版本中为您提供总共 22 列:5.5.27更高版本

TRIGGER_CATALOG 
TRIGGER_SCHEMA
TRIGGER_NAME
EVENT_MANIPULATION
EVENT_OBJECT_CATALOG
EVENT_OBJECT_SCHEMA 
EVENT_OBJECT_TABLE
ACTION_ORDER
ACTION_CONDITION
ACTION_STATEMENT
ACTION_ORIENTATION
ACTION_TIMING
ACTION_REFERENCE_OLD_TABLE
ACTION_REFERENCE_NEW_TABLE
ACTION_REFERENCE_OLD_ROW
ACTION_REFERENCE_NEW_ROW
CREATED 
SQL_MODE
DEFINER 
CHARACTER_SET_CLIENT
COLLATION_CONNECTION
DATABASE_COLLATION

回答by Kainda

You can use below to find a particular trigger definition.

您可以在下面使用来查找特定的触发器定义。

SHOW TRIGGERS LIKE '%trigger_name%'\G

or the below to show all the triggers in the database. It will work for MySQL 5.0 and above.

或下面显示数据库中的所有触发器。它适用于 MySQL 5.0 及更高版本。

SHOW TRIGGERS\G

回答by sunil

For showing a particular trigger in a particular schema you can try the following:

要在特定模式中显示特定触发器,您可以尝试以下操作:

select * from information_schema.triggers where 
information_schema.triggers.trigger_name like '%trigger_name%' and 
information_schema.triggers.trigger_schema like '%data_base_name%'