【转】 #1451 - Cannot delete or update a parent row: a foreign key constraint fails 问题的解决办法
2014-06-25 14:11
417 查看
转载地址:http://blog.csdn.net/donglynn/article/details/17056099
错误
SQL 查询:DELETE FROM `zmax_lang` WHERE CONVERT( `zmax_lang`.`lang` USING utf8 ) = 'fr' LIMIT 1
MySQL 返回:
![](http://www.changtiejinghua.com/phpMyAdmin/themes/original/img/b_help.png)
#1451 - Cannot delete or update a parent row: a foreign key constraint fails (`myreview/zmax_text`, CONSTRAINT `zmax_text_ibfk_1` FOREIGN KEY (`lang`) REFERENCES `zmax_lang` (`lang`))
以上是因为,改条记录的某个字段作为innodb的另外一个表的外链。而在删除操作时会自动检查外链。解决的办法之一是,不检查外链,只需将执行语句前加上下句即可:
SET FOREIGN_KEY_CHECKS = 0;
DELETE FROM `zmax_lang` WHERE CONVERT( `zmax_lang`.`lang` USING utf8 ) = 'fr' LIMIT 1
相关文章推荐
- #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 问题的解决办法
- Cannot delete or update a parent row: a foreign key constraint fails 问题的解决办法
- ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails...问题解决
- 1451, 'Cannot delete or update a parent row: a foreign key constraint fails.MYsql执行删除时报错。
- 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
- jbpm4 jbpm4_execution “Cannot delete or update a parent row: a foreign key constraint fails” 异常解决
- 关闭外键检查 ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails
- Cannot delete or update a parent row: a foreign key constraint fails解决方法
- jbpm Cannot delete or update a parent row: a foreign key constraint fails
- Cannot delete or update a parent row: a foreign key constraint fails
- ERROR 1217 (23000) at line 19: Cannot delete or update a parent row: a foreign key constraint fails
- Cannot delete or update a parent row: a foreign key constraint fails
- [MySQL]MYSQL: 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
- 【转】表删除时 Cannot delete or update a parent row: a foreign key constraint fails 异常处理
- 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
- Cannot delete or update a parent row: a foreign key constraint fails