Name

SHOW TRIGGERS

Synopsis

SHOW TRIGGERS STATUS [FROM database]
[LIKE 'pattern'|WHERE expression]

This statement displays a list of triggers on the server. The database to which triggers are related may be given in the FROM clause; the default is the current database. The LIKE or WHERE clauses can be used to list triggers based on a particular naming pattern. The LIKE clause includes the name of the table with which the trigger is associated or a pattern for the table name that includes wildcards (%). With the WHERE clause, you can use the names of fields in the results to create an expression that sets a condition determining the results returned. Here is an example using this statement:

SHOW TRIGGERS LIKE 'students' \G

*************************** 1. row ***************************
  Trigger: students_deletion
    Event: DELETE
    Table: students
Statement: BEGIN
INSERT INTO students_deleted
(student_id, name_first, name_last)
VALUES(OLD.student_id, OLD.name_first, OLD.name_last);
END
   Timing: BEFORE
  Created: NULL
 sql_mode:
  Definer: root@localhost

See CREATE TRIGGER earlier in this chapter for more information on triggers and to see how the trigger shown was created.

Get MySQL in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.