What is Trigger in SQL?
Answers (1)
Add AnswerA trigger is one kind of stored procedure in the database that is automatically called/invokes whenever a special event in the database occurs.
For EX, a trigger can be invoked when certain table columns are being updated or deleted.
There are two types of triggers:
- DDL Trigger (Data Definition Language)
- DML Trigger (Data Manipulation Language)
The DDL triggers are invoked to DDL (Data Definition Language) command that starts with Create, Alter, and Drops, For EX- Create_table, Create_view, drop_table, Drop_view, and Alter_table.
The DML triggers are invoked to DML (Data Manipulation Language) command that starts with Insert, Update and Delete. For EX- insert_table, Update_view and Delete_table.
For more details with example, you can refer to the below article.
How To Use Triggers In SQL