当前位置:网站首页>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;
边栏推荐
- pickle. Load error [attributeerror: can't get attribute 'volatile' on < module '\u main']
- Les canaux de culture intensive s'efforcent de développer Fu Xin et Wei Shi jiajie pour organiser une conférence de formation sur les nouveaux produits
- Basic knowledge of audio coding and decoding
- 简版拼多多商品数据
- 精耕渠道共謀發展 福昕攜手偉仕佳傑開展新產品培訓大會
- OpenCV视频质量检测--清晰度检测
- Ubuntu14 install MySQL and configure root account local and remote access
- Download (export) PDF template file (such as approval form), and report error: invalid nested tag * * * found, expected closing tag***
- 新版国标GB28181视频平台EasyGBS如何配置WebRTC视频流格式播放?
- [to.Net] C set class source code analysis
猜你喜欢
精耕渠道共谋发展 福昕携手伟仕佳杰开展新产品培训大会
After studying 11 kinds of real-time chat software, I found that they all have these functions
白盒加密技术浅理解
wireshark报文分析tcp,ftp
Axure does not display catalogs
智慧防疫系统为建筑工地复工复产提供安全保障
AAAI2020: Real-time Scene Text Detection with Differentiable Binarization
Parallelism, concurrency and life cycle of threads
见证时代!“人玑协同 未来已来”2022弘玑生态伙伴大会开启直播预约
Dlib+opencv library for fatigue detection
随机推荐
H264 encoding profile & level control
新版国标GB28181视频平台EasyGBS如何配置WebRTC视频流格式播放?
The difference between indexof and includes
DTD modeling
正则表达式=Regex=regular expression
下载(导出)pdf模板文件(比如:审批单),报错:Invalid nested tag *** found, expected closing tag ***
大厂音视频职位面试题目--今日头条
Instagram 为何从内容共享平台变成营销工具?独立站卖家如何利用该工具?
Reading the paper [learning to discretely compose reasoning module networks for video captioning]
Facebook聊单,SaleSmartly有妙招!
Solidity - truncated and checked modes of arithmetic operations - new features of 0.8.0
[English grammar] Unit1 articles, nouns, pronouns and numerals
AAAI2020: Real-time Scene Text Detection with Differentiable Binarization
Case sharing: basic networking configuration of QinQ
论文泛读【FiLM: Visual Reasoning with a General Conditioning Layer】
wireshark报文分析tcp,ftp
Methods of finding various limits
GB28181之SIP协议
118. Yanghui triangle
H264编码profile & level控制