在删除mysql数据库表数据时报错:
报错信息:1451 -Cannot delete or update a parent row: a foreign key constraint fails()
解决方法:
set FOREIGN_KEY_CHECKS=0; #设置外键约束检查关闭
DELETE FROM table; #删除表数据
SET FOREIGN_KEY_CHECKS=1; #开启外键约束检查
报错信息:1451 -Cannot delete or update a parent row: a foreign key constraint fails()
解决方法:
set FOREIGN_KEY_CHECKS=0; #设置外键约束检查关闭
DELETE FROM table; #删除表数据
SET FOREIGN_KEY_CHECKS=1; #开启外键约束检查