Friday 7 June 2013

basic of trigger

1)What is Trigger?

A trigger is a special kind of a store procedure that executes in response to certain action
on the table like insertion, deletion or updation of data. It is a database object which is bound
to a table and is executed automatically. You can’t explicitly invoke triggers.
The only way to do this is by performing the required action no the table that they are assigned to.


2) Types of Trigger

There are three action query types that you use in SQL which are INSERT, UPDATE and DELETE.
So, there are three types of triggers and hybrids that come from mixing and matching the events and
timings that fire them.

Basically, triggers are classified into two main types:-

(i) After Triggers
(ii) Instead Of Triggers


(i) After Triggers

These triggers run after an insert, update or delete on a table. They are not supported for views.
after triggers can be classified further into three types as:


(a) After insert Trigger.


This type of trigger is fired after insert statement.

(b) After update Trigger.

This type of trigger is fired after update statement.

(c) After delete Trigger.

This type of trigger is fired after delete statement.

(ii) Instead Of Triggers

This type of trigger is fired inplace of triggering action .They are supported for views.
e.g :if you write a instead of insert trigger ,and if you try to insert records on that table then .
inplace of insert statement a trigger is fired .

instead of Triggers can be classified further into three types as:-


(a) instead of insert Trigger.

This type of trigger is fired inplace of insert statement.

(b) instead of update Trigger.

This type of trigger is fired inplace of update statement.

(c) instead of delete Trigger.

This type of trigger is fired inplace of delete statement.

No comments:

Post a Comment

if you have any doubt any suggestions do comment