其实问题不大,主要就是自己不够细心。
根据给出的错误提示,我仔细对比了一下主表和设有外键的表,发现设置的外键和对应的主键表的主键值不一致,重新修改后又报错了,原来是我主表的id字段类型是varchar,而我添加数据时添加的是int型数据,最后把把这个问题一改就不会报错了。
相关文章
- 11-30admin添加用户时报错:(1452, 'Cannot add or update a child row: a foreign key constraint fails (`mxonline`.`django_admin_l
- 11-30Error Code: 1452 Cannot add or update a child row: a foreign key constraint fails
- 11-30外键添加失败:java.sql.SQLException: Cannot add or update a child row: a foreign key constraint fails
- 11-301452, 'Cannot add or update a child row: a foreign key constraint fails
- 11-30workbench添加不了外键Cannot add or update a child row: a foreign key constraint fails原因
- 11-30报错:Cannot add or update a child row: a foreign key constraint fails
- 11-30MySQL设置外键报错 #1452 - Cannot add or update a child row: a foreign key constraint fails 解决方法
- 11-30Error 'Cannot add or update a child row: a foreign key constraint fails故障解决
- 11-30insert时报Cannot add or update a child row: a foreign key constraint fails (`yanchangzichan`.`productstatusrecord`, CONSTRAINT `p_cu` FOREIGN KEY (`cid`) REFERENCES `customer` (`cid`))错误
- 11-30hibernate4一对多关联多方多写一次外键导致无法创建java.lang.NullPointerException以及Cannot add or update a child row: a foreign key constraint fails