老师,我添加或修改的时候遇到外键问题,网上我找过试了都没成功
来源:7-3 商品类别批量添加后端开发
慕斯卡6955199
2018-02-23
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`o2o`.`tb_product_category`, CONSTRAINT `fk_procate_shop` FOREIGN KEY (`shop_id`) REFERENCES `tb_shop` (`shop_id`))
; SQL []; Cannot add or update a child row: a foreign key constraint fails (`o2o`.`tb_product_category`, CONSTRAINT `fk_procate_shop` FOREIGN KEY (`shop_id`) REFERENCES `tb_shop` (`shop_id`)); nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`o2o`.`tb_product_category`, CONSTRAINT `fk_procate_shop` FOREIGN KEY (`shop_id`) REFERENCES `tb_shop` (`shop_id`))
1回答
-
同学好,此类错误比较明显呢,违反了shopid的外键约束,即添加商品类别信息的时候,添加的shop_id在tb_shop这张表里不存在。以后类似的问题希望同学能尝试去解决哦,码农必备的基本功咱必须得攻克:)
042018-03-01
相似问题