
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How can we get the metadata of triggers?
It can be done with the help of the INFORMATION_SCHEMA database. Following statement will give us the metadata of triggers −
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)
- Related Articles
- How can we get the metadata of MySQL events?
- How can we use INFORMATION_SCHEMA to get the details about triggers in a particular database?
- How can we check the list of all triggers in a database?
- How can we use SIGNAL statement with MySQL triggers?
- How can we emulate CHECK CONSTRAINT by using triggers?
- How can we see the information on triggers order in case of multiple triggers\nfor same event and action time?
- How can we see the metadata of a view(s) stored in a particular MySQL database?
- How we can find all the triggers associated with a particular MySQL table?
- How to get all the MySQL triggers and the triggers for only the current database
- How can we create multiple MySQL triggers for the same trigger event and action time?
- How can we get the structure of a MySQL view as we can get the structure of a MySQL table?
- How can we get the definition of a MySQL view as we can get the definition of a MySQL table?
- How can we get the sorted MySQL output?
- How to use Boto3 to get the details of multiple triggers at a time?
- In which order MySQL will invoke the triggers if we created multiple triggers of same event and action time?

Advertisements