INFORMATION_SCHEMA TRIGGERS
The INFORMATION_SCHEMA TRIGGERS dictionary view provides information about triggers. To view information about triggers on a table, you must have the TRIGGER privilege on the table.
The INFORMATION_SCHEMA TRIGGERS dictionary view contains the following fields:
| Field Name | Description |
|---|---|
| TRIGGER_CATALOG | The name of the catalog to which the trigger belongs. This value is always def. |
| TRIGGER_SCHEMA | The name of the schema (database) to which the trigger belongs. |
| TRIGGER_NAME | The trigger name. |
| EVENT_MANIPULATION | The trigger event. This is the type of operation that activates the trigger on the associated table. The value can be INSERT (a row is inserted), DELETE (a row is deleted), or UPDATE (a row is modified). |
| EVENT_OBJECT_CATALOG、EVENT_OBJECT_SCHEMA、 EVENT_OBJECT_TABLE | Each trigger is associated with one table. These fields respectively indicate the catalog and schema (database) in which the table is located, as well as the table name. The value of EVENT_OBJECT_CATALOG is always def. |
| ACTION_ORDER | The order and position of the trigger operation in the list of triggers on the same table with the same EVENT_MANIPULATION and ACTION_TIMING values. |
| ACTION_CONDITION | This value is always NULL. |
| ACTION_STATEMENT | The statement executed when the trigger is activated. The text is encoded in UTF-8. |
| ACTION_ORIENTATION | This value is always ROW . |
| ACTION_TIMING | Whether the trigger is activated before or after the trigger event. The value can be BEFORE or AFTER. |
| ACTION_REFERENCE_OLD_TABLE | This value is always NULL . |
| ACTION_REFERENCE_NEW_TABLE | This value is always NULL . |
| ACTION_REFERENCE_OLD_ROW、ACTION_REFERENCE_NEW_ROW | The identifiers of the old and new columns. The value of ACTION_REFERENCE_OLD_ROW is always OLD. The value of ACTION_REFERENCE_NEW_ROW is always NEW. |
| 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. |
| SQL_MODE | The SQL mode in effect when the trigger was created. |
| DEFINER | The account specified in the DEFINER clause (usually the user who created the trigger), in the format 'user_name'@'host_name'. |
| 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. |
Here is an example:
SELECT * FROM INFORMATION_SCHEMA.TRIGGERS
WHERE TRIGGER_SCHEMA='test' AND TRIGGER_NAME='test_trg'\G
*************************** 1. row ***************************
TRIGGER_CATALOG: def
TRIGGER_SCHEMA: test
TRIGGER_NAME: test_trg
EVENT_MANIPULATION: UPDATE
EVENT_OBJECT_CATALOG: def
EVENT_OBJECT_SCHEMA: test
EVENT_OBJECT_TABLE: test
ACTION_ORDER: 0
ACTION_CONDITION: NULL
ACTION_STATEMENT: TRIGGER test_trg BEFORE UPDATE ON test
FOR EACH ROW
BEGIN
IF NEW.user_num < 1 THEN
SET NEW.user_num = 1;
ELSEIF NEW.user_num > 45 THEN
SET NEW.user_num= 45;
END IF;
END
ACTION_ORIENTATION: ROW
ACTION_TIMING: BEFORE
ACTION_REFERENCE_OLD_TABLE: NULL
ACTION_REFERENCE_NEW_TABLE: NULL
ACTION_REFERENCE_OLD_ROW: OLD
ACTION_REFERENCE_NEW_ROW: NEW
CREATED: 2022-05-18 18:07:51.994639
SQL_MODE: STRICT_ALL_TABLES,NO_ZERO_IN_DATE
DEFINER: 'root'@'%'
CHARACTER_SET_CLIENT: utf8mb4
COLLATION_CONNECTION: utf8mb4
DATABASE_COLLATION: utf8mb4