Home > Database > Mysql Tutorial > body text

How do we get the metadata of a trigger?

王林
Release: 2023-08-30 22:45:02
forward
574 people have browsed it

How do we get the metadata of a trigger?

This can be done with the help of the INFORMATION_SCHEMA database. The following statement will give us the metadata of the trigger -

mysql> Select trigger_schema, trigger_name, action_statement
    -> from information_schema.triggers\G
*************************** 1. row ***************************
  trigger_schema: query
    trigger_name: trigger_before_delete_sample
action_statement: BEGIN
SET @count = if (@count IS NULL, 1, (@count+1));
INSERT INTO sample_rowaffected values (@count);
END
*************************** 2. row ***************************
  trigger_schema: query
    trigger_name: before_inser_studentage
action_statement: IF NEW.age < 0 THEN SET NEW.age = 0;
END IF
*************************** 3. row ***************************
  trigger_schema: sys
    trigger_name: sys_config_insert_set_user
action_statement: BEGIN IF @sys.ignore_sys_config_triggers != true AND
NEW.set_by IS NULL THEN SET NEW.set_by = USER(); END IF; END
*************************** 5. row ***************************
  trigger_schema: sys
    trigger_name: sys_config_update_set_user
action_statement: BEGIN IF @sys.ignore_sys_config_triggers != true AND
NEW.set_by IS NULL THEN SET NEW.set_by = USER(); END IF; END
4 rows in set (0.03 sec)
Copy after login

The above is the detailed content of How do we get the metadata of a trigger?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template