데이터베이스
-
[mysql]외래키 제약조건 변경데이터베이스 2020. 12. 18. 11:15
외래키로 참조당하고있는 데이터를 삭제하면 에러가 발생한다. 10:07:39 DELETE from product where product_code = '002' Error Code: 1451. Cannot delete or update a parent row: a foreign key constraint fails (`bizcos`.`recipe_mng`, CONSTRAINT `product_code` FOREIGN KEY (`product_code`) REFERENCES `product` (`product_code`)) 0.016 sec 이 문제를 해결하기 위해 참조 당하는 데이터를 삭제하면 참조 하고있는 데이터도 자동으로 같이 삭제해주는 옵션을 추가한다. 이 설정을 위해 우선 테이블의 제약조건이름을 알..