truncate带有外键的表出错
truncate带有外键的表出错
ERROR 1701 (42000): Cannot truncate a table referenced in a foreign key constraint (mytest
.instance
, CONSTRAINT instance_ibfk_1
FOREIGN KEY (GroupID
) REFERENCES mytest
.mygroup
(ID
))
解决方法:
SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE table1;
TRUNCATE table2;
SET FOREIGN_KEY_CHECKS = 1;