当前位置:网站首页>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;
边栏推荐
- H264编码profile & level控制
- Nacos configuration file publishing failed, please check whether the parameters are correct solution
- Opencv video quality diagnosis - VIDEO occlusion diagnosis
- 新版国标GB28181视频平台EasyGBS如何配置WebRTC视频流格式播放?
- 【英语语法】Unit1 冠词、名词、代词和数词
- IPv4 address, subnet mask, gateway
- ddr4测试-2
- Brpc understanding
- uni-app商品分类
- Detailed explanation of JUnit unit test framework
猜你喜欢

Native JS creates a calendar - supports mouse wheel scrolling to select months - and can be ported to any framework

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

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

Facebook聊单,SaleSmartly有妙招!
Use the uni app demo provided by Huanxin to quickly realize one-on-one chat

论文阅读【Learning to Discretely Compose Reasoning Module Networks for Video Captioning】

音视频、编解码相关电子书、小工具,打包奉送!

uni-app商品分类

精耕渠道共谋发展 福昕携手伟仕佳杰开展新产品培训大会

研究了11种实时聊天软件,我发现都具备这些功能…
随机推荐
【To .NET】C#集合类源码解析
原生js打造日程表-支持鼠标滚轮滚动选择月份-可以移植到任何框架中
音频编解码基础知识
IPv4 address, subnet mask, gateway
[to.Net] C set class source code analysis
Contos 7 搭建sftp之创建用户、用户组以及删除用户
Ffmpeg error code
Opencv video quality diagnosis - VIDEO occlusion diagnosis
面试题 16.16. 部分排序-双指针法
A brief understanding of white box encryption technology
新版国标GB28181视频平台EasyGBS如何配置WebRTC视频流格式播放?
微信小程序 navigator点击后有阴影 ,去掉navigator阴影效果
GB28181的NAT穿透
Task: denial of service DOS
Instagram 为何从内容共享平台变成营销工具?独立站卖家如何利用该工具?
After studying 11 kinds of real-time chat software, I found that they all have these functions
Dlib+opencv library for fatigue detection
Why has instagram changed from a content sharing platform to a marketing tool? How do independent sellers use this tool?
Implement a Prometheus exporter
How to redraw the header of CListCtrl in MFC