首页 > 数据库技术 > 详细

mysql8.0添加外键报错 1824 - Failed to open the referenced table 'tb_dept1'

时间:2021-06-07 23:13:46      阅读:170      评论:0      收藏:0      [点我收藏+]

CREATE TABLE tb_emp5
(
id INT(11) PRIMARY KEY,
name VARCHAR(25),
deptId INT(11),
salary FLOAT,
CONSTRAINT fk_emp_dept1 FOREIGN KEY(deptId) REFERENCES tb_dept1(id)
);

 

报错

1824 - Failed to open the referenced table ‘tb_dept1‘

 

创建外键报错分析,constraint 为关键字,fk_emp_dept1为外键名称  ,foreign key(deptId) 为定义外键的关键字(此为从表)

tb_dept1(id)(此为主表),以上报错是数据库中没有创建tb_dept1的数据表。

mysql8.0添加外键报错 1824 - Failed to open the referenced table 'tb_dept1'

原文:https://www.cnblogs.com/CHINA-YPT/p/14860387.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!