LXM21

2020-07-06   阅读量: 709

Mysql

SQL报错:外键约束

扫码加入数据分析学习群

Error Code: 1452. Cannot add or update a child row: a foreign key constraint fails (`test`.`employee1`, CONSTRAINT `employee1_ibfk_1` FOREIGN KEY (`deptid`) REFERENCES `dept` (`deptno`))

image.png

建表代码如图

image.png

解决:

没有导入部门信息,先导入部门信息,再导入员工表信息,因为员工表受外键约束(部门表的编号)

image.png

image.png

22.4569 5 5 关注作者 收藏

评论(0)


暂无数据

推荐课程