当前位置:网站首页>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;
边栏推荐
- 原生js打造日程表-支持鼠标滚轮滚动选择月份-可以移植到任何框架中
- Junit单元测试框架详解
- ES6中的代理proxy
- 精耕渠道共謀發展 福昕攜手偉仕佳傑開展新產品培訓大會
- Native JS creates a calendar - supports mouse wheel scrolling to select months - and can be ported to any framework
- [info() method in org.slf4j.logger]
- English grammar_ Adjective / adverb Level 3 - precautions
- Dom4j parsing XML, XPath retrieving XML
- win10下使用msys+vs2019编译ffmpeg源码
- 241. Different Ways to Add Parentheses
猜你喜欢
[Mori city] random talk on GIS data (I)
Actual combat of flutter - fast implementation of audio and video call application
Thesis reading [distinctive late semantic graph for video capturing]
uni-app微信小程序一键登录获取权限功能
Audio and video, encoding and decoding related e-books, gadgets, packaged for free!
测试自学人必看:软件测试如何找测试项目?
Intensive cultivation of channels for joint development Fuxin and Weishi Jiajie held a new product training conference
【To .NET】C#集合类源码解析
商业智能BI开发和报表开发有什么本质区别?
奔赴山海之前,毕业季一定要做的那些事情
随机推荐
torch.nn.functional.interpolate函数
703. 数据流中的第 K 大元素
【无标题】
[go ~ 0 to 1] day 4 June 30 defer, structure, method
Axure does not display catalogs
How to correctly use vertx to operate redis (3.9.4 with source code analysis)
uni-app商品分类
ubuntu14安装MySQL并配置root账户本地与远程访问
CMU AI PhD 第一年总结
torch. nn. functional. Interpolate function
Transaction isolation level gap lock deadlock
Contos 7 set up SFTP to create users, user groups, and delete users
Salesmartly has some tricks for Facebook chat!
Ffmpeg error code
Task: denial of service DOS
原生js打造日程表-支持鼠标滚轮滚动选择月份-可以移植到任何框架中
AAAI2020: Real-time Scene Text Detection with Differentiable Binarization
精耕渠道共謀發展 福昕攜手偉仕佳傑開展新產品培訓大會
[info() method in org.slf4j.logger]
ES6中的代理proxy