What is a trigger in SQL?
A trigger is a special procedure that runs automatically on a specific event in the database.
It "fires" on INSERT, UPDATE, or DELETE operations against a table.
Example
sql
CREATE TRIGGER log_update
AFTER UPDATE ON users
FOR EACH ROW
INSERT INTO user_logs(user_id, action_time)
VALUES (NEW.id, NOW());Here the trigger fires after an update (AFTER UPDATE) on the users table and writes the change information into the user_logs table.
So a trigger is the database's automatic reaction to a data change, similar to "an event with an action attached".
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.