1
SQLBeginner#aggregates#nulls
A block of SQL that runs automatically BEFORE or AFTER an INSERT, UPDATE or DELETE on a table. Useful for auditing and derived columns, but heavy triggers hide logic and hurt performance.
CREATE TRIGGER audit_salary AFTER UPDATE ON employees FOR EACH ROW INSERT INTO salary_audit(emp_id, old_sal, new_sal, changed_at) VALUES (OLD.id, OLD.salary, NEW.salary, NOW());