Forked from rafaeltedesco/remove_manual_id_trigger.sql
Created
November 22, 2022 13:13
-
-
Save vinibortoletto/1e3b6fdbe7072a4552475cbb92aebfbb to your computer and use it in GitHub Desktop.
Guarantee that user cannot insert a manual id on a auto_increment field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP TRIGGER IF EXISTS sakila.bf_insert_actor; | |
DELIMITER $$ | |
CREATE TRIGGER bf_insert_actor | |
BEFORE INSERT ON sakila.actor | |
FOR EACH ROW | |
BEGIN | |
IF NEW.actor_id IS NOT NULL THEN | |
SET NEW.actor_id = null; | |
END IF; | |
END $$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment