当前位置:网站首页>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;
边栏推荐
- Task: denial of service DOS
- ffmpeg AVFrame 转 cv::Mat
- [info() method in org.slf4j.logger]
- ubuntu14安装MySQL并配置root账户本地与远程访问
- 论文泛读【FiLM: Visual Reasoning with a General Conditioning Layer】
- Optaplanner learning notes (I) case cloud balance
- 【英语语法】Unit1 冠词、名词、代词和数词
- OpenCV视频质量诊断----视频遮挡诊断
- Botu V16 obtains the system time and converts it into a string
- Simplified pinduoduo product data
猜你喜欢
使用环信提供的uni-app Demo,快速实现一对一单聊

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

Wireshark packet analysis TCP, FTP

微信公众号开发相关流程及功能介绍

Introduction to relevant processes and functions of wechat official account development

【To .NET】C#集合类源码解析

Optaplanner learning notes (I) case cloud balance

sql查询去重统计的方法总结

After studying 11 kinds of real-time chat software, I found that they all have these functions

118. Yanghui triangle
随机推荐
原生js打造日程表-支持鼠标滚轮滚动选择月份-可以移植到任何框架中
论文阅读【Discriminative Latent Semantic Graph for Video Captioning】
Shell高级进阶
[English grammar] Unit1 articles, nouns, pronouns and numerals
optaplanner学习笔记(一)案例Cloud balance
Analysis of GetMessage underlying mechanism
web开发常用的开源框架的开源协议整理
Shell advanced
ffmpeg 错误码
Basic knowledge of audio coding and decoding
Optaplanner learning notes (I) case cloud balance
宝,运维100+服务器很头疼怎么办?用行云管家!
Introduction to relevant processes and functions of wechat official account development
Facebook聊单,SaleSmartly有妙招!
English grammar_ Adjective / adverb Level 3 - precautions
Collect Tiktok video
【森城市】GIS数据漫谈(一)
Axure does not display catalogs
Dlib+opencv library for fatigue detection
GB28181之SIP协议