What is a Trigger in MySQL? Define different types of Trigger

Answer

A trigger is a set of code which is executed in response to some event.

E.g Update employee_perfomance table when a new task is inserted in task table. Here, the trigger is “update” and the event is “inserting a new row”.

A trigger in MySQL is created using CREATE TRIGGER trigger_name. we need to specify the trigger type.  

  • When do you want the trigger to execute? This can be either BEFORE or AFTER
  • What do you expect the trigger to do? This can be INSERT UPDATE DELETE
  • On which table you want the trigger to run? (using ON table_name)
  • Lastly, though not mandatory, is FOR EACH ROW if it is used then the trigger will fire once for all records of the table. If it is not specified the trigger will fire once only regardless of the number of records being updated

All sql dba Questions

Ask your interview questions on sql-dba

Write Your comment or Questions if you want the answers on sql-dba from sql-dba Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---