Sunday 13 November 2016

SQL Triggers

SQL Trigger


- Triggers are special kind of stored procedures that get executed automatically when an INSERT, UPDATE or DELETE operations takes place on a table. 
- Triggers can't be invoked on demand. They get triggered only when an association action(INSERT, UPDATE, DELETE) happens on the table.

Types of Triggers: 2 types

- After Triggers
- Instead of Triggers

After Triggers

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

- AFTER INSERT Trigger - This trigger is fired after an INSERT on the table.
- AFTER UPDATE Trigger - This trigger is fired after an UPDATE on the table.
- AFTER DELETE Trigger - This trigger is fired after an DELETE on the table.

Example

     Coming Soon....





Instead of Triggers


- This trigger executes in place of the triggering action.
- INSTEAD of Triggers can be specified on both the tables and views.

 These are classified into three types.
  - INSTEAD OF INSERT Trigger
  - INSTEAD OF UPDATE Trigger
  - INSTEAD OF DELETE Trigger


Example

     Coming Soon....



Thanks for taking your valuable time to reading my blog. -Sadiq.


No comments: