0 votes
in Sql by
What is SQL Trigger?

2 Answers

0 votes
by

The Trigger allows us to execute a batch of SQL code when table event occurs (INSERT, UPDATE or DELETE commands are executed against a specific table).

0 votes
by

A trigger is a set of SQL statements that reside in a system catalog. It is a special type of stored procedure that is invoked automatically in response to an event. It allows us to execute a batch of code when an insert, update or delete command is run against a specific table because the trigger is the set of activated actions whenever DML commands are given to the system.

SQL triggers have two main components one is action, and another is an event. When certain actions are taken, an event occurs as a result of those actions.

We use the CREATE TRIGGER statement for creating a trigger in SQL. Here is the syntax:

CREATE TRIGGER trigger_name      

    (AFTER | BEFORE) (INSERT | UPDATE | DELETE)    

         ON table_name FOR EACH ROW      

         BEGIN      

        --variable declarations      

        --trigger code      

        END;  

Related questions

0 votes
asked Jun 12, 2023 in Sql by Robin
0 votes
0 votes
asked Nov 8, 2021 in Sql by rajeshsharma
...