CREATE TRIGGER log_deleted_student
AFTER DELETE ON students
FOR EACH ROW
INSERT INTO student_log (student_id, action)
VALUES (OLD.id, 'deleted');
Every time a row is deleted from students, the trigger adds a row to student_log. OLD is the row before the change and NEW is the row after it. Use triggers carefully, because they run hidden in the background.
Learn more about the similar topics:
| Tutorials |
| No Content Found. |
| Exercises & Assignments |
| No Content Found. |
| Interview Questions & Answers |
| No Content Found. |