ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

How to implement trigger at mysql database?

user-image
تم إضافة السؤال من قبل amr abdelhafeez , Consultant , AlWalan Technology
تاريخ النشر: 2014/10/19
Peter Onwuzuruigbo
من قبل 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 }

المزيد من الأسئلة المماثلة