-
[SQL] java.sql.SQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails
2022. 6. 29.
java.sql.SQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails
참조테이블에 없는 값을 추가해서 발생한 오류이다.
참조 무결성에 따라서 부모키에 해당하는 값만 넣을 수 있음.
참조하는 테이블에 데이터를 먼저 추가한 후, 참조받는 테이블에 데이터를 추가하면 오류 해결.
(외래키로 연결한 값을 동일하게 줘야 한다)
References https://live-everyday.tistory.com/188
MySQL Error Code: 1452. Cannot add or update a child row 해결
에러메시지 Error Code: 1452. Cannot add or update a child row: a foreign key constraint fails (`vanilla`.`#sql-1c10_73`, CONSTRAINT `document_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `_user` (`id`..
live-everyday.tistory.com
'Programming > 에러노트' 카테고리의 다른 글
[AJAX] URL에러 상태로 성공 (0) 2022.07.23 [Tomcat] The origin server did not find a current representation for the target resource or is not willing to disclose that one exists. (0) 2022.06.30 [SpringFramework/스프링프레임워크] org.springframework.context.support.DefaultMessageSourceResolvable (0) 2022.06.27 input값 에러 (0) 2022.06.24 getter/setter 오류 (0) 2022.06.20 댓글