Skip to content

Instantly share code, notes, and snippets.

@gbarreiro
Created August 20, 2020 15:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gbarreiro/44920f74efe06efa99fa5a7c99665602 to your computer and use it in GitHub Desktop.
Save gbarreiro/44920f74efe06efa99fa5a7c99665602 to your computer and use it in GitHub Desktop.
MySQL cheatsheet: triggers
-- Triggered after a INSERT operation on "Students" table
CREATE TRIGGER my_trigger AFTER INSERT ON Students FOR EACH ROW
BEGIN
-- ... instructions to be performed ... --
END;
-- Triggered before a DELETE operation on "Teachers" table
CREATE TRIGGER my_trigger BEFORE DELETE ON Teachers FOR EACH ROW
BEGIN
-- ... instructions to be performed ... --
END;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment