当前位置:网站首页>mysql 報錯 Can‘t create table ‘demo01.tb_Student‘ (errno: 150)*
mysql 報錯 Can‘t create table ‘demo01.tb_Student‘ (errno: 150)*
2022-07-01 19:40: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;
边栏推荐
- 118. Yanghui triangle
- Oracle物理体系结构
- Compile ffmpeg source code with msys+vs2019 under win10
- sql查询去重统计的方法总结
- Regular expression =regex=regular expression
- Ubuntu14 install MySQL and configure root account local and remote access
- OpenCV视频质量诊断----视频遮挡诊断
- Go Language Advanced
- H264 encoding profile & level control
- ubuntu14安装MySQL并配置root账户本地与远程访问
猜你喜欢

智慧防疫系统为建筑工地复工复产提供安全保障

Uni app product classification

奔赴山海之前,毕业季一定要做的那些事情

MySQl的基本使用

Salesmartly has some tricks for Facebook chat!

新版国标GB28181视频平台EasyGBS如何配置WebRTC视频流格式播放?

Audio and video, encoding and decoding related e-books, gadgets, packaged for free!

Axure does not display catalogs

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

Introduction and installation of crunch, and making password dictionary with crunch
随机推荐
Nat penetration of gb28181
Extensive reading of the paper [film: visual reasoning with a general condition layer]
新版国标GB28181视频平台EasyGBS如何配置WebRTC视频流格式播放?
Compile ffmpeg source code with msys+vs2019 under win10
703. The k-th element in the data flow
微信小程序 navigator点击后有阴影 ,去掉navigator阴影效果
EasyGBS网络不稳定情况下重复请求视频拉流问题的优化
AAAI2020: Real-time Scene Text Detection with Differentiable Binarization
Methods of finding various limits
【无标题】
Collect Tiktok video
ffmpeg 错误码
IPv4 address, subnet mask, gateway
ubuntu14安装MySQL并配置root账户本地与远程访问
Analysis of GetMessage underlying mechanism
Uni app product classification
703. 数据流中的第 K 大元素
Shell高级进阶
Proxy in ES6
SIP protocol of gb28181