You can use the SHOW CREATE TRIGGER statement to view the information about a trigger.
Syntax:
SHOW CREATE TRIGGER trigger_name;
This statement requires that the table associated with the trigger have the TRIGGER privilege.
The output of the SHOW CREATE TRIGGER statement contains the following fields:
Trigger: the name of the trigger.sql_mode: the SQL mode used when the trigger is executed.SQL Original Statement: theCREATE TRIGGERstatement that defines the trigger.character_set_client: the value of thecharacter_set_clientsystem variable in the current session when the trigger was created.collation_connection: the value of thecollation_connectionsystem variable when the trigger was created.Database Collation: the collation of the database to which the trigger is associated.Created: the date and time when the trigger was created. The type of the value isTIMESTAMP(2)(with the fractional part in hundredth seconds).
You can also obtain the information about a trigger from the INFORMATION_SCHEMA TRIGGERS table. For more information, see INFORMATION_SCHEMA TRIGGERS.
Example:
obclient> 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