Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

How to implement trigger at mysql database?

user-image
Question added by amr abdelhafeez , Consultant , AlWalan Technology
Date Posted: 2014/10/19
Peter Onwuzuruigbo
by Peter Onwuzuruigbo , Software Developer , Internet Experts

Firstly, triggers are ways to tell the dbms (database management system) to execute an action whenever a type of action happens to a database object (mostly tables).

 

Example, we can tell the MySQL DBMS to do something whenever a new row is inserted into a table. We can use a trigger on that table to achieve this.

 

CREATE TRIGGER triggerName BEFORE DELETE ON tableName

FOR EACH ROW function.

 

In the short illustration above, we told the dbms (mysql) to run function BEFORE a row is DELETEd from the tableName table. triggerName is just an identifier or a name for the trigger.

The syntax is:

CREATE [DEFINER = { user | CURRENT_USER }] TRIGGER trigger_name trigger_time trigger_event ON tbl_name FOR EACH ROW trigger_body trigger_time: { BEFORE | AFTER } trigger_event: { INSERT | UPDATE | DELETE }

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.