当前位置:网站首页>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;
边栏推荐
- CMU AI PhD 第一年总结
- H264编码profile & level控制
- Proxy in ES6
- Case sharing: basic networking configuration of QinQ
- 下载(导出)pdf模板文件(比如:审批单),报错:Invalid nested tag *** found, expected closing tag ***
- nacos启动失败问题解决与总结
- mysql 报错 Can‘t create table ‘demo01.tb_Student‘ (errno: 150)*
- 音频编解码基础知识
- Introduction to relevant processes and functions of wechat official account development
- 奔赴山海之前,毕业季一定要做的那些事情
猜你喜欢

商业智能BI开发和报表开发有什么本质区别?

EasyGBS主子码流都为H.265时,切换出现花屏如何解决?

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

DTD modeling

Uni app wechat applet one click login to obtain permission function

Shell advanced

wireshark报文分析tcp,ftp

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

Parallelism, concurrency and life cycle of threads

原生js打造日程表-支持鼠标滚轮滚动选择月份-可以移植到任何框架中
随机推荐
English语法_形容词/副词3级 -注意事项
ES6中的代理proxy
ffmpeg 音频相关命令
703. 数据流中的第 K 大元素
Ffmpeg common commands (2)
IPv4 address, subnet mask, gateway
axure不显示元件库
新版国标GB28181视频平台EasyGBS如何配置WebRTC视频流格式播放?
How to correctly use vertx to operate redis (3.9.4 with source code analysis)
【org.slf4j.Logger中info()方法】
ddr4测试-2
Ffmpeg avframe to cv:: mat
GetMessage底层机制分析
OpenCV视频质量诊断----视频遮挡诊断
线程的并行、并发、生命周期
Solidity - truncated and checked modes of arithmetic operations - new features of 0.8.0
EasyGBS主子码流都为H.265时,切换出现花屏如何解决?
sql查询去重统计的方法总结
Contos 7 set up SFTP to create users, user groups, and delete users
原生js打造日程表-支持鼠标滚轮滚动选择月份-可以移植到任何框架中