转载地址:http://blog.csdn.net/donglynn/article/details/17056099

错误

SQL 查询:

DELETE FROM `zmax_lang` WHERE CONVERT( `zmax_lang`.`lang` USING utf8 ) = 'fr' LIMIT 1

MySQL 返回:

#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 问题的解决办法的更多相关文章

  1. 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 问题的解决办法查询:DELETE ...

  2. 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 constr ...

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

    mysql> SET FOREIGN_KEY_CHECKS = 0; Query OK, 0 rows affected (0.02 sec)   mysql> delete from r ...

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

    centos7.5 删除表空间文件失败 问题: mysql> alter table country discard tablespace; ERROR 1451 (23000): Cannot ...

  5. 【转】表删除时 Cannot delete or update a parent row: a foreign key constraint fails 异常处理

    转载地址:http://lijiejava.iteye.com/blog/790478 有两张表,结构如下: t_item:                          t_bid: id    ...

  6. 表删除时 Cannot delete or update a parent row: a foreign key constraint fails 异常处理

    有两张表,结构如下: t_item:                          t_bid: id        int                     id        int n ...

  7. MySQL主从复制中断,报“Error on master: message (format)='Cannot delete or update a parent row: a foreign key constraint fails' error code=1217” 错误

    前几天,发现从库挂了,具体报错信息如下: 分析思路 1. 因为我采用的是选择性复制,只针对以下几个库进行复制: card,upay,deal,monitor,collect.所以,不太可能出现对于sa ...

  8. Hibernate级联删除时:Cannot delete or update a parent row: a foreign key constraint fails异常

    在删除主表数据时,报了一个异常 Cannot delete or update a parent row: a foreign key constraint fails 原因是主表中还包含字表的数据, ...

  9. MySQL:ERROR 1217 (23000): 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 constraint fa ...

随机推荐

  1. c#中的math类

    http://wenku.baidu.com/link?url=TliiVtdB8IeO3wiM9mVSD-3wLZcLum7dsXlEZgSKawo6x-qvE_G3VL_yDa3ZQ_9ZFlGG ...

  2. Quartz.net 的简单使用,创建定时任务

    ISchedulerFactory sf = new StdSchedulerFactory(); sched = sf.GetScheduler(); JobDetail job = new Job ...

  3. 对Oracle10g rac srvctl命令使用理解

    srvctl命令是RAC维护中最常用到的命令,也最为复杂,使用这个命令可以操作CRS上的Database,Instance,ASM,Service.Listener和Node Application资 ...

  4. Web前端开发基础 第三课(与浏览者交互)

    来自慕课网,整理 语法: <form method="传送方式" action="服务器文件"> 讲解: 1.<form> :<f ...

  5. windows 快捷键

    Windows 系统 f6  在同一个应用的不同窗口进行切换 ctrl-shift 拖动,创建文件快捷方式 shift 右键点击文件 可以出现复制路径的菜单 WIN键组合键 Windows Key + ...

  6. laravel redis

    安装配置redis服务器 $ wget http://download.redis.io/releases/redis-3.0.5.tar.gz $ tar xzf redis-.tar.gz $ c ...

  7. Ubuntu 安装java环境搭建

    1.下载JDK 8从http://www.oracle.com/technetwork/java/javasebusiness/downloads/选择下载JDK的最新版本 JDK 8. 2.解压文件 ...

  8. tomcat chinese miscode and chinese input in IDEA

    JAVA_OPTS="$JAVA_OPTS -Djavax.servlet.request.encoding=UTF-8 -Dfile.encoding=UTF -8 -Duser.lang ...

  9. ListView简单使用

    先上效果: 主要实现了Listview的绑定和点击事件.项目资源结构如下: 先创建一个动物类,用来装载数据: Animal类如下: package com.example.simplelistview ...

  10. HTML页面主体常用设置

    1.定义网页背景颜色:<body bgcolor="red"> <body bgcolor="#0fc"> 2.设置背景图片: < ...