navicat+MySQL设置外键MySQL “Cannot add or update a child row: a foreign key constraint fails”

MySQL “Cannot add or update a child row: a foreign key constraint fails”
MySQL“无法添加或更新子行:外键约束失败”
意思就是本表的外键 在另一表中没有数据 需要先迁移数据
举例:
需要seller表中sellerId作为外键 对应到assert表中的sellerId主键
如图 先把数据都弄成一致
数据迁移
这样就可以再取设置外键就不会有MySQL “Cannot add or update a child row: a foreign key constraint fails”的错误了
设置外键

发布了67 篇原创文章 · 获赞 32 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/qq_42391904/article/details/102489942