Triggers in SQL

Trigger are a special kind of SQL statements that are executed on when an event is triggered on the table. These events include INSERT, UPDATE and DELETE. So whenever insert, update or delete operation is performed on the table corresponding trigger get executed.

Types of triggers 

There are two types of triggers in SQL.

  1. Afrer Triggers
  2. Intead of Triggers

After Trigger

After trigger gets executed after insert, update or delete operation in performed on the table. On the basis of these operations After trigger is classified in below 3 categories

  1. After INSERT Trigger
  2. After UPDATE Trigger
  3. After DELETE Trigger

Instead of Trigger

As the name specifies these triggers get executed instead of executing SQL statement. Suppose an instead of trigger is defined for delete statement so whenever a delete statement is issued for that table, SQL executes instead of triggers and actual delete statement not executes.

Instead of trigger can be classified in following 3 categories based on Insert, update and delete operations

  1. Instead of INSERT Trigger
  2. Instead of UPDATE Trigger
  3. Instead of DELETE Trigger

Share this chapter
Comments
comments powered by Disqus

Navigation

Social Media