Skip to content

Instantly share code, notes, and snippets.

@uncoded-ro
Created April 5, 2020 21:38
Show Gist options
  • Save uncoded-ro/9301d8a77ef5947c27ef904135494444 to your computer and use it in GitHub Desktop.
Save uncoded-ro/9301d8a77ef5947c27ef904135494444 to your computer and use it in GitHub Desktop.
USE sakila;
DROP TRIGGER IF EXISTS delete_before_actor;
DELIMITER $$
CREATE TRIGGER delete_before_actor
BEFORE DELETE
ON actor FOR EACH ROW
BEGIN
INSERT INTO actor_log (event, actor_id, first_name, last_name)
VALUES ('delete', old.actor_id, old.first_name, old.last_name);
END $$
DELIMITER ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment