Mysql之1451 - Cannot delete or update a parent row: a foreign key constraint fails...解决办法记录

Posted cpl9412290130

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Mysql之1451 - Cannot delete or update a parent row: a foreign key constraint fails...解决办法记录相关的知识,希望对你有一定的参考价值。

今天使用delete语句删除一张表中的一条信息时,提示了这么一个错误:1451 - Cannot delete or update a parent row: a foreign key constraint fails...错误代码为1451

在这里参考了一位园友的解决方案mysql删除外链解决办法,如下:

  • 关闭外键约束
    • SET FOREIGN_KEY_CHECKS=0;  
  • 语句执行
    • DELETE FROM blog_blog WHERE blog_blog.id=91;
  • 删除完成后,重新开启外键约束
    • SET FOREIGN_KEY_CHECKS=1;

然后就可以删除成功了。

以上是关于Mysql之1451 - Cannot delete or update a parent row: a foreign key constraint fails...解决办法记录的主要内容,如果未能解决你的问题,请参考以下文章

关于mysql中[Err] 1451 -Cannot delete or update a parent row: a foreign key constraint fails

MYSQL: Cannot delete or update a parent row: a foreign key constraint fails

mysql ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constrain fails

ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails

Flask中的(pymysql.err.IntegrityError)(1451,'无法删除或更新父行:外键约束失败...')

PHP MySQL Delete From 之 Delete