MySql数据库插入或更新报错:Cannot add or update a child row: a foreign key constraint fails
具体报错信息:
Cannot add or update a child row: a foreign key constraint fails (`xxx`.`AAA`, CONSTRAINT `tb_competitionmsg_ibfk_2` FOREIGN KEY (`organizerid`) REFERENCES `BBB` (`id`))
报错信息分析:
XXX数据库中的 AAA表 中的 organizerid字段 是BBB表中的id的外键,但是要插入的organizerid值在id中没有匹配成功。
解决:
检查插入的数据是否正确
在BBB表中的id字段中添加上所要插入的值。
MySql数据库插入或更新报错:Cannot add or update a child row: a foreign key constraint fails的更多相关文章
- MySQL设置外键报错 #1452 - Cannot add or update a child row: a foreign key constraint fails 解决方法
MySQL数据库,当我尝试在A表中设置B表的主键为外键时,报出错误:#1452 - Cannot add or update a child row: a foreign key constraint ...
- Mysql数据库报错:Cannot add or update a child row: a foreign key constraint fails(添加多对多关系)
#创建班级表 class Classes(models.Model): title = models.CharField(max_length=32) n=models.ManyToManyField ...
- admin添加用户时报错:(1452, 'Cannot add or update a child row: a foreign key constraint fails (`mxonline`.`django_admin_l
在stackoverflow找到答案: DATABASES = { 'default': { ... 'OPTIONS': { "init_command": "SET ...
- 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 ...
- 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 ...
- 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 ...
- 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 constraint ...
- 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 ...
- 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 这个该如何解决 可以这样解决: S ...
随机推荐
- 辨析:Object与Instance都是对象,概念上没有区别。
Object与Instance有重要的区别:Object是客观世界中存在的实体:Instance是将Object虚拟到计算机世界的实例,它的生存方式是可运行的代码,它的生存环境是计算机中的内存资源,生 ...
- Python常用模块之re
1.正则表达式规则 2.Python正则常用模块 2.1.re.match与re.search 函数说明:re.match 尝试从字符串的起始位置匹配一个模式,如果不是起始位置匹配成功的话,match ...
- SPOJ8222 NSUBSTR - Substrings(后缀自动机)
You are given a string S which consists of 250000 lowercase latin letters at most. We define F(x) as ...
- ABAP术语-Key Field
Key Field 原文:http://www.cnblogs.com/qiangsheng/archive/2008/02/28/1084421.html Field which is part o ...
- 根据坐标计算距离(mysql函数)
CREATE DEFINER=`root`@`localhost` FUNCTION `getDistance`(lng1 ) BEGIN DECLARE result double; DECLARE ...
- Java中事务总结详解(精华)
1.什么是JAVA事务? 通常的观念认为,事务仅与数据库相关. 事务必须服从ISO/IEC所制定的ACID原则.ACID是原子性(atomicity).一致性(consistency).隔离性 (is ...
- JS学习- ES6 async await使用
async 函数是什么?一句话,它就是 Generator 函数的语法糖. 使用场景常常会遇到,请求完一个接口,拿完值再去请求另外一个接口,我们之前回调callback函数处理,如果很多的情况下,看起 ...
- Nodejs 使用 SerialPort 调用串口
工作经常使用串口读写数据,electron 想要替代原来的客户端,串口成了必须要突破的障碍. get --> https://github.com/EmergingTechnologyAdvi ...
- Flask初学者:视图函数和类视图
当一个url请求进入后台时,一般有两种方式来进行处理:视图函数和类视图.视图函数直接使用一个函数来进行处理并返回数据给浏览器,类视图则是使用类来进行处理并返回的,所以当需要进行的处理比较简单,则可以考 ...
- Apache Struts最新漏洞 远程代码执行漏洞预警 2018年11月08日
2018年11月8日,SINE安全监控检测中心,检测到Apache Struts官方更新了一个Struts漏洞补丁,这个漏洞是Apache Struts目前最新的漏洞,影响范围较广,低于Apache ...