当前位置:网站首页>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;
边栏推荐
- [pytorch record] distributed training dataparallel and distributeddataparallel of the model
- Go Language Advanced
- 精耕渠道共謀發展 福昕攜手偉仕佳傑開展新產品培訓大會
- Extensive reading of the paper [film: visual reasoning with a general condition layer]
- How to correctly use vertx to operate redis (3.9.4 with source code analysis)
- Werewolf killing strategy: do you think I'm easy to cheat? Who do we believe!
- 703. The k-th element in the data flow
- Analysis of GetMessage underlying mechanism
- Facebook聊单,SaleSmartly有妙招!
- optaplanner学习笔记(一)案例Cloud balance
猜你喜欢

数字化转型企业成功的关键,用数据创造价值

研究了11种实时聊天软件,我发现都具备这些功能…

Parallelism, concurrency and life cycle of threads

Junit单元测试框架详解

论文泛读【FiLM: Visual Reasoning with a General Conditioning Layer】

What must be done in graduation season before going to Shanhai

Instagram 为何从内容共享平台变成营销工具?独立站卖家如何利用该工具?

测试自学人必看:软件测试如何找测试项目?
![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]

精耕渠道共谋发展 福昕携手伟仕佳杰开展新产品培训大会
随机推荐
Witness the times! "The future of Renji collaboration has come" 2022 Hongji ecological partnership conference opens live broadcast reservation
Download (export) PDF template file (such as approval form), and report error: invalid nested tag * * * found, expected closing tag***
Intensive cultivation of channels for joint development Fuxin and Weishi Jiajie held a new product training conference
【org.slf4j.Logger中info()方法】
Facebook聊单,SaleSmartly有妙招!
PostgreSQL varchar[] array type operation
[SQL optimization] the difference between with as and temporary tables
How to redraw the header of CListCtrl in MFC
Basic knowledge of audio coding and decoding
Write it down once Net travel management background CPU Explosion Analysis
Detailed explanation of JUnit unit test framework
Introduction to relevant processes and functions of wechat official account development
MySQl的基本使用
Collation of open source protocols of open source frameworks commonly used in Web Development
[go ~ 0 to 1] day 4 June 30 defer, structure, method
CMU AI PhD 第一年总结
Wechat applet navigator has a shadow after clicking. Remove the shadow effect of navigator
What must be done in graduation season before going to Shanhai
Solution and summary of Nacos startup failure
After studying 11 kinds of real-time chat software, I found that they all have these functions