What are triggers?

Category: SQLWhat are triggers?
Editor">Editor Staff asked 2 years ago

 What are triggers?

1 Answers
Editor">Editor Staff answered 2 years ago

Triggers in SQL is kind of stored procedures used to create a response to a specific action performed on the table such as INSERT, UPDATE or DELETE. You can invoke triggers explicitly on the table in the database.
Action and Event are two main components of SQL triggers. When certain actions are performed, the event occurs in response to that action.
Syntax:

CREATE TRIGGER name {BEFORE|AFTER} (event [OR..]}
ON table_name [FOR [EACH] {ROW|STATEMENT}]
EXECUTE PROCEDURE functionname {arguments}