Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

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

user-image
Question added by Muhammad Obaidullah , sales senior , khalifa Steel Industries
Date Posted: 2015/11/18
Gayasuddin Mohammed
by 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
by 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

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