Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

How to implement trigger at mysql database?

user-image
Question ajoutée par amr abdelhafeez , Consultant , AlWalan Technology
Date de publication: 2014/10/19
Peter Onwuzuruigbo
par 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

Avez-vous besoin d'aide pour créer un CV ayant les mots-clés recherchés par les employeurs?