Skip to main content

SHOW CREATE TRIGGER

This statement displays the CREATE TRIGGER statement used to create the trigger.

The syntax of the SHOW CREATE TRIGGER statement is as follows:

SHOW CREATE TRIGGER trigger_name;

This statement requires the TRIGGER privilege on the table associated with the trigger.

The SHOW CREATE TRIGGER statement outputs the following information:

  • Trigger: the name of the trigger.

  • sql_mode: the SQL mode in effect when the trigger is executed.

  • SQL Original Statement: the CREATE TRIGGER statement used to define the trigger.

  • character_set_client: the value of the character_set_client system variable in the current session when the trigger was created.

  • collation_connection: the value of the collation_connection system variable in the current session when the trigger was created.

  • Database Collation: the collation of the database associated with the trigger.

  • Created: the date and time when the trigger was created. The value is of the TIMESTAMP(2) type (with the fractional part in hundredths of a second).

You can also obtain trigger information from the INFORMATION_SCHEMA TRIGGERS table. For more information, see INFORMATION_SCHEMA TRIGGERS.

Here is an example of the SHOW CREATE TRIGGER statement:

SHOW CREATE TRIGGER test_trg;
+--------------+----------+-----------------+-----------------------+----------------------+--------------------+
| Trigger | sql_mode | SQL Original Statement | character_set_client | collation_connection | Database Collation |
+--------------+----------+-----------------+-----------------------+----------------------+--------------------+
| test_trg | STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE |CREATE TRIGGER test_trg BEFORE UPDATE ON test FOR EACH ROW BEGIN IF NEW.user_num < 1 THENSET NEW.user_num = 1; ELSEIF NEW.user_num > 45 THEN SET NEW.user_num= 45; END IF;END | utf8mb4 | utf8mb4 | utf8mb4 |
+--------------+----------+-----------------+-----------------------+----------------------+--------------------+--------+
1 row in set