인지용

Cannot truncate a table referenced in a foreign key constraint 에러 Mysql 본문

에러 해결

Cannot truncate a table referenced in a foreign key constraint 에러 Mysql

인지용 2021. 11. 7. 18:14

외래키가 존재하는 테이블 삭제방법

 

> set FOREIGN_KEY_CHECKS = 0;
Query OK, 0 rows affected (0.000 sec)

> truncate 테이블명;
Query OK, 0 rows affected (0.351 sec)

> set FOREIGN_KEY_CHECKS = 1;
Query OK, 0 rows affected (0.000 sec)

 

 

 

 

출처

https://devpouch.tistory.com/111

 

[mysql] foreign key가 존재하는 table을 truncate/delete할때 constraint 에러 문제 해결하기

문제상황 truncate 테이블명; ERROR 1701 (42000): Cannot truncate a table referenced in a foreign key constraint (`DB명`.`참조하는 테이블`, CONSTRAINT `test` FOREIGN KEY (`외래키`) REFERENCES `DB명`.`..

devpouch.tistory.com