MySQL清空表提示Cannot truncate a table referenced in a foreign key constraint
MySQL清空表提示Cannot truncate a table referenced in a foreign key constraint
在MySQL执行truncate table xxx时, 出现了这个报错[Err] 1701 -Cannot truncate a table referenced in a foreign key constraint..
意思是 无法截断外键约束中引用的表
解决办法
- mysql中运行
SET FOREIGN_KEY_CHECKS=0,删除外键约束 - 之后执行
SET FOREIGN_KEY_CHECKS=1,启动外键约束 - 在重新
truncate table xxx;清空就可以了

浙公网安备 33010602011771号