Suggest an editImprove this articleRefine the answer for “What is a trigger in SQL?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)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, e.g. an `AFTER UPDATE` trigger writes change information into a separate log table. **Key point:** a trigger is the database's **automatic reaction** to a data change, similar to "an event with an action attached".Shown above the full answer for quick recall.Answer (EN)ImageA **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".For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.