Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- Query String
- git rebase -i
- 참조무결성
- 1450
- programmers
- Late row lookup
- code --no-sandbox
- debezium
- Cannot delete or update a parent row: a foreign key constraint fails
- 1452
- foreign key constraint fails
- git reflog
- 제약 조건
- kafka-connect
- 페이지네이션 최적화
- kafka connect
- 23000
- constraint fails
- event loop
- reflog
- 문자열 검증
- 페이지네이션
- Cannot add or update a child row: a foreign key constraint fails
- Pagination Optimization
- kafkaconnect
- Invalid character found in method name
- API 설계
- jdbc connector
- Git
- Path Variable
Archives
- Today
- Total
Kawaii_Jordy
[참조무결성 제약조건] 1451 (23000) Cannot delete or update a parent row: a foreign key constraint fails 해결 본문
취준/DB
[참조무결성 제약조건] 1451 (23000) Cannot delete or update a parent row: a foreign key constraint fails 해결
Kawaii_Jordy 2021. 6. 8. 20:19Problem
A 테이블에서 B 테이블을 참조하고 있는 경우, A 테이블을 삭제할 때 참조무결성 제약조건에 의해 테이블이 삭제 되지 않는 상황이다.
Solution
1) 먼저 외래키 제약조건 체크를 해제 시키고
2) 원하는 테이블을 삭제한다.
3) 추후의 DB 정합성을 위해 외래키 제약조건을 다시 체크 하도록 설정을 변경한다
mysql> SET FOREIGN_KEY_CHECKS = 0; // 외래키 제약조건 체크 해제
mysql> DELETE TABLE [테이블명] or TRUNCATE [테이블명] OR DROP [테이블명]
mysql> SET FOREIGN_KEY_CHECKS = 1; // 외래키 제약조건 체크
'취준 > DB' 카테고리의 다른 글
[Encoding] charset, collation 조회 및 수정 (0) | 2021.06.09 |
---|---|
[Mysql, Maria] TIMEDIFF with option (0) | 2021.06.03 |
[Sequelize] bind (0) | 2021.06.02 |
[Sequelize] transaction (0) | 2021.05.26 |
[Sequlize] nodejs sequelize raw-queries (0) | 2021.05.12 |
Comments