当前位置:网站首页>mysql 报错 Can‘t create table ‘demo01.tb_Student‘ (errno: 150)*
mysql 报错 Can‘t create table ‘demo01.tb_Student‘ (errno: 150)*
2022-07-01 18:45:00 【欲与宇语】
mysql 添加外键的时候发现报错 150
提示:mysql 添加外键的时候发现报错 ,但是自己外键的类型是一样的,并且另外一个表也存在这个字段
报错内容:Can’t create table ‘demo01.tb_Student’ (errno: 150)
外键用法介绍:
CONSTRAINT Fk_Class_Student FOREIGN KEY(classId) references tb_class(classId)
CONSTRAINT 约束名字 FOREIGN KEY(外键名字) references 要外键关联的表名(字段名)
CREATE TABLE tb_class(
classId int PRIMARY KEY AUTO_Increment,
ClassName varchar(20) not null
);
CREATE TABLE tb_Student(
StudentId int primary key Auto_increment,
StudentName varchar(20),
classId int not NULL,
CONSTRAINT Fk_Class_Student FOREIGN KEY(classId) references tb_class(classId)
)
解决方案:
提示:在创建 tb_Student时后面添加 ENGINE = MYISAM;
CREATE TABLE tb_class(
classId int PRIMARY KEY AUTO_Increment,
ClassName varchar(20) not null
);
CREATE TABLE tb_Student(
StudentId int primary key Auto_increment,
StudentName varchar(20),
classId int not NULL,
CONSTRAINT Fk_Class_Student FOREIGN KEY(classId) references tb_class(classId)
)ENGINE = MYISAM;
边栏推荐
- Introduction to relevant processes and functions of wechat official account development
- ffmpeg AVFrame 转 cv::Mat
- Brpc understanding
- 【To .NET】C#集合类源码解析
- axure不显示元件库
- Go语言高级
- Go Language Advanced
- Interview questions for audio and video positions in Dachang -- today's headline
- 奔赴山海之前,毕业季一定要做的那些事情
- Optaplanner learning notes (I) case cloud balance
猜你喜欢
使用环信提供的uni-app Demo,快速实现一对一单聊

Interview questions for audio and video positions in Dachang -- today's headline

ddr4测试-2

如何正确使用Vertx操作Redis(3.9.4带源码分析)

Witness the times! "The future of Renji collaboration has come" 2022 Hongji ecological partnership conference opens live broadcast reservation

Summary of SQL query de duplication statistics methods

XML语法、约束
![Extensive reading of the paper [film: visual reasoning with a general condition layer]](/img/69/f4ba37a7eae34a7e698127c31b0161.png)
Extensive reading of the paper [film: visual reasoning with a general condition layer]

Dom4j parsing XML, XPath retrieving XML

Optaplanner learning notes (I) case cloud balance
随机推荐
After studying 11 kinds of real-time chat software, I found that they all have these functions
118. 杨辉三角
How to redraw the header of CListCtrl in MFC
XML syntax, constraints
Introduction and installation of crunch, and making password dictionary with crunch
任务:拒绝服务DoS
智慧防疫系统为建筑工地复工复产提供安全保障
pickle. Load error [attributeerror: can't get attribute 'volatile' on < module '\u main']
Introduction to relevant processes and functions of wechat official account development
见证时代!“人玑协同 未来已来”2022弘玑生态伙伴大会开启直播预约
Shell advanced
论文泛读【FiLM: Visual Reasoning with a General Conditioning Layer】
English语法_形容词/副词3级 -注意事项
事务隔离级别 gap锁 死锁
Detailed explanation of JUnit unit test framework
wireshark报文分析tcp,ftp
Actual combat of flutter - fast implementation of audio and video call application
The difference between indexof and includes
What must be done in graduation season before going to Shanhai
微信小程序 navigator点击后有阴影 ,去掉navigator阴影效果