What is a "TRIGGER" in SQL?

Forums SQLWhat is a "TRIGGER" in SQL?
Staff asked 2 years ago

Answers (1)

Add Answer
Nayan Raval Marked As Accepted
Staff answered 2 years ago

In a system catalogue, a trigger is a collection of SQL statements. It’s a form of stored procedure that gets called automatically when something happens. Because the trigger is the set of activated activities whenever DML commands are delivered to the system, it allows us to run a batch of code whenever an insert, update or delete command is issued against a certain table.

An action and an event are the two main components of SQL triggers. As a result of certain acts being taken, an event occurs.

In SQL, we utilize the CREATE TRIGGER statement to create a trigger. The syntax is as follows:

 

CREATE TRIGGER trigger_name      
    (AFTER | BEFORE) (INSERT | UPDATE | DELETE)    
         ON table_name FOR EACH ROW      
         BEGIN      
        --variable declarations      
        --trigger code      
        END;

 

Subscribe

Select Categories