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

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

متابعة

What do you know about Trigger in SQL, How does it work? please describe with example.

user-image
تم إضافة السؤال من قبل Muhammad Obaidullah , sales senior , khalifa Steel Industries
تاريخ النشر: 2015/11/18
Gayasuddin Mohammed
من قبل Gayasuddin Mohammed , Advocate , Practicing Law before High Court at Hyderabad

Triggers in database is for the purpose of triggering or raising alarm if anything unwanted has been doing or anything wanted to be executed based on any execution of statement(like dependency).

There are three types of triggers based on1) Insert2) Delete and3) update. 

Simple example for triggers is the audit purpose i.e. if any record is getting entered into one table which has on insert trigger on that table, had raise a trigger of insert to insert the record automatically in a audit table with the user id , date, etc for the purpose of audit.

similar way of any deletion takes place, it will have to insert into audit table automatically with the respective details and the same way for the updation as well.

This is the simple example I gave here, but there are so many requirements or dependencies  in real time can be implemented using the triggers in database.

My2 cents. Thanks for the invitation.

 

 

 

Ronald Pedraja
من قبل Ronald Pedraja , Software Developer , Seameo Innotech

Triggers in SQL are SQL statements that as the name states "trigger" when a certain condition is met.

 

for example. if you we're to create a trigger ON CREATE, that SQL statement will run/execute when an entity or item is CREATED.

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