In this post I am going to mention details of Database Triggers on a high level.
Database Triggers:
Is a block of statements that are implicitly fired by a database when INSERT, UPDATE, DELETE statements issued against given table.
- Triggers are stored in a database separately from their associated tables.
- Triggers can be defined only on tables, not on views except instead-of Trigger.
- However, triggers on base table(s) of a view are fired if an INSERT, UPDATE, or DELETE statement is issued against a view.
- Trigger Event or Statement: This can be an Insert, Update, Delete.
- Trigger Constraint or Restriction: Optional. (a Boolean expression must be true for a trigger to fire.)
- Trigger Action: It is a procedure that contains a SQL statement along with other criteria.
Trigger configuration: We can have Triggers at the following levels...
- STATEMENT level
- ROW level
- On INSERT or UPDATE or DELETE operations levels
- Also, can be executed at BEFORE or AFTER events
Trigger Management:
- We can Drop Trigger
- DISABLE or ENABLE Triggers from firing at any specific event or statement (see above)
Special Trigger category:
- INSTEAD OF Triggers:
- It provide a way of modifying views that can not be modified directly using DML (Insert. Update. & Delete) statements.
- It is called INSTEAD OF trigger because, unlike other types of triggers, a database fires the trigger instead of executing the triggering statement.
- We can write normal INSERT, UPDATE, and DELETE statements against the view and INSTEAD OF trigger is fired to update the underlying tables appropriately.
- INSTEAD OF triggers are activated for each row of the view that gets modified.
References:
- For further reading, please refer to the following link: https://docs.oracle.com/cd/B19306_01/server.102/b14220/triggers.htm
0 comments:
Post a Comment