Created
November 22, 2022 12:25
-
-
Save rafaeltedesco/9f2b00dfb5b64ea7f13e91aba6fe838a 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 hidden or 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