Database Trigger
Database Triggers are set of actions written in the code which are implicitly called whenever certain events or actions occur on the table in a database. Triggers can restrict data access, perform logging into the system as well as maintain audit of the database.
Triggers acts on the tables but not the views. Triggers do not accept a parameter or argument for its execution. They do not need an explicit execute statement for their execution. But database triggers could store the data changes into the temporary tables. Certain triggers need not be written explicitly, they are default triggers that come up with the DBMS purchase.
Examples include whenever a user logs in or logs out, a database administrator shuts down the application, and the database default triggers are executed. Database triggers let us create additional relationships between the databases. Triggers are independent of the user or the application which causes the triggering event.
Types of triggers:
1. Row Triggers - Executes for each row of the table
2. Statement Triggers - Execute once per each statement like ‘INSERT’, ‘DELETE’,’UPDATE’. The Insert Event (Whenever an insert action occurs, the insert trigger gets executed), the Delete Event (Whenever a delete action occurs, the delete trigger gets executed) and the Update Event (Whenever a row is modified or updated in the table, the update trigger gets executed)
Triggering Methods:
1. BEFORE Trigger - Before triggers have the time of execution of the trigger before the event has occurred.
2. AFTER Trigger - After triggers have the time of execution of the trigger after the event has occurred.
3. INSTEAD OF Trigger - The statement that gets executed instead of the original trigger statements. Instead of are triggered whenever the event is on the view.
When we write trigger statements for interlinked events, it would end up creating nested database triggers or cascaded database triggers. In a large database such cascaded triggers would be difficult to manage. An example for a cascaded database trigger is as below.

Related posts:
- What is SQL SQL is the computer language to manage data in the...
- Database Normalization Normalization is the process of creating and organizing data in...
- Transactional Database Transactional Database has the functionality or an important role required...
- Database Replication Database replication is a method to create and replicate multiple...
- Relational Database Relational Database, the data or information are gathered and arranged...
No Responses to “Database Trigger”
No feedback yet.