当前位置:网站首页>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;
边栏推荐
- Why has instagram changed from a content sharing platform to a marketing tool? How do independent sellers use this tool?
- uni-app微信小程序一键登录获取权限功能
- Summary of SQL query de duplication statistics methods
- Shell advanced
- Live HLS protocol
- H264编码profile & level控制
- XML语法、约束
- Transform + ASM data
- Helium transmission line of lake shore cryostat
- 118. Yanghui triangle
猜你喜欢

Dom4j parsing XML, XPath retrieving XML
![Reading the paper [learning to discretely compose reasoning module networks for video captioning]](/img/a2/acdaebeb67ec4bcb01c8ff4bbd1d1e.png)
Reading the paper [learning to discretely compose reasoning module networks for video captioning]

Detailed explanation of JUnit unit test framework

wireshark报文分析tcp,ftp

sql查询去重统计的方法总结

精耕渠道共謀發展 福昕攜手偉仕佳傑開展新產品培訓大會

A brief understanding of white box encryption technology
使用环信提供的uni-app Demo,快速实现一对一单聊

XML语法、约束

Solution and summary of Nacos startup failure
随机推荐
Write it down once Net travel management background CPU Explosion Analysis
Ffmpeg avframe to cv:: mat
PostgreSQL varchar[] array type operation
研究了11种实时聊天软件,我发现都具备这些功能…
Uni app product classification
torch.nn.functional.interpolate函数
精耕渠道共谋发展 福昕携手伟仕佳杰开展新产品培训大会
Why has instagram changed from a content sharing platform to a marketing tool? How do independent sellers use this tool?
XML syntax, constraints
Compile ffmpeg source code with msys+vs2019 under win10
商业智能BI开发和报表开发有什么本质区别?
Crunch简介、安装,使用Crunch制作密码字典
论文阅读【Discriminative Latent Semantic Graph for Video Captioning】
uni-app微信小程序一键登录获取权限功能
Opencv video quality detection -- sharpness detection
H264 encoding profile & level control
Opencv video quality diagnosis - VIDEO occlusion diagnosis
Implement a Prometheus exporter
CMU AI PhD 第一年总结
正则表达式=Regex=regular expression