当前位置:Gxlcms > 数据库问题 > 数据库添加数据报错:Cannot add or update a child row: a foreign key constraint fails

数据库添加数据报错:Cannot add or update a child row: a foreign key constraint fails

时间:2021-07-01 10:21:17 帮助过:28人阅读

  也就是说tb_shop表中的涉及到的外键是fk_shop_profile,表tb_shop中的列owner_id和表tb_person_info中的列user_id有外键关联,现在这里的数据插入出现了问题。数据库如下:

技术图片

技术图片

技术图片

 

  对比表结构,没有发现问题,那只能是表中内部字段的问题了,经过询问,检测,发现虽然之前都是设置的自增,但不知道什么时候在shop_id字段输入的id号输入成了10。创建出user_id 和tb_shop里面的owner_id 不对应,修改后重新运行后成功添加了字段。

技术图片

 

数据库添加数据报错:Cannot add or update a child row: a foreign key constraint fails

标签:row   16px   数据   add   img   upd   表结构   code   use   

人气教程排行