How do you list all triggers in a MySQL database?

MysqlTriggers

Mysql Problem Overview


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

Mysql Solutions


Solution 1 - Mysql

The command for listing all triggers is:

show triggers;

or you can access the INFORMATION_SCHEMA table directly by:

select trigger_schema, trigger_name, action_statement
from information_schema.triggers

Solution 2 - Mysql

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.27 and Above

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

Solution 3 - Mysql

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.

SHOW TRIGGERS\G

Solution 4 - Mysql

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%'

Solution 5 - Mysql

You can use MySQL Workbench: Connect to the MySQL Server Select DB

  • tables
  • on the table name line click the edit icon (looks like a work tool)
  • in the table edit window - Click the tab "Triggers"
  • on the Triggers list click th eTrigger name to get its source code

Solution 6 - Mysql

This sentence could contribute to solving the problem:

select LOWER(concat('delimiter |', '\n', 'create trigger %data_base_name%.', TRIGGER_NAME, '\n', 
'    ', ACTION_TIMING, ' ', EVENT_MANIPULATION, ' on %data_base_name%.', EVENT_OBJECT_TABLE, ' for each row', '\n',
ACTION_STATEMENT, '\n',
'|')) AS TablaTriggers from information_schema.triggers where 
information_schema.triggers.trigger_schema like '%data_base_name%'

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionHarryView Question on Stackoverflow
Solution 1 - MysqlHarryView Answer on Stackoverflow
Solution 2 - MysqlPragnesh KariaView Answer on Stackoverflow
Solution 3 - MysqlKaindaView Answer on Stackoverflow
Solution 4 - MysqlsunilView Answer on Stackoverflow
Solution 5 - Mysqluser14570900View Answer on Stackoverflow
Solution 6 - MysqlLeon GomezView Answer on Stackoverflow