Communiquez avec les autres et partagez vos connaissances professionnelles

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

Suivre

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

user-image
Question ajoutée par Muhammad Obaidullah , sales senior , khalifa Steel Industries
Date de publication: 2015/11/18
Gayasuddin Mohammed
par 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
par 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.

More Questions Like This

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