当前位置:网站首页>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;
边栏推荐
猜你喜欢

How to solve the problem of splash screen when the main and sub code streams of easygbs are h.265?

正则表达式=Regex=regular expression

How to correctly use vertx to operate redis (3.9.4 with source code analysis)

商业智能BI开发和报表开发有什么本质区别?
![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]

求各种极限的方法

Axure does not display catalogs

ubuntu14安装MySQL并配置root账户本地与远程访问

为什么一定要从DevOps走向BizDevOps?

线程的并行、并发、生命周期
随机推荐
uni-app微信小程序一键登录获取权限功能
【英语语法】Unit1 冠词、名词、代词和数词
Solution and summary of Nacos startup failure
Junit单元测试框架详解
狼人杀攻略:你当我好骗吗,我们相信谁!
Axure does not display catalogs
The use of subplot function in MATLAB
【森城市】GIS数据漫谈(一)
Compile ffmpeg source code with msys+vs2019 under win10
Ffmpeg audio related commands
Regular expression =regex=regular expression
Methods of finding various limits
论文泛读【FiLM: Visual Reasoning with a General Conditioning Layer】
Optaplanner learning notes (I) case cloud balance
DDR4 test-2
Crunch简介、安装,使用Crunch制作密码字典
ffmpeg 错误码
学习笔记【gumbel softmax】
为什么一定要从DevOps走向BizDevOps?
win10下使用msys+vs2019编译ffmpeg源码