Error
Cannot delete or update a parent row: a foreign key constraint fails
Issue:
mysql> update User SET id=6 where id = 8;
ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (`database_name`.`table_name`, CONSTRAINT `FK_35jtu0049tkg8m9twhc03ii9` FOREIGN KEY (`customer`) REFERENCES `user` (`id`))
Solution:
SET foreign_key_checks = 1;
; execute code with constraint restrictions here
SET foreign_key_checks = 0;
No comments:
Post a Comment