您的位置:首页技术文章
文章详情页

导入数据库文件报错 #1215 - Cannot add foreign key constraint

【字号: 日期:2022-06-03 18:19:58浏览:79作者:猪猪

问题描述

SQL 查询:

CREATE TABLE `blog_article` ( `id` int(4) NOT NULL AUTO_INCREMENT COMMENT '博文主键', `title` varchar(200) NOT NULL COMMENT '博文标题', `order` int(4) NOT NULL DEFAULT '0' COMMENT '排序', `content` text NOT NULL COMMENT '内容', `cat_id` int(4) NOT NULL COMMENT '所属分类', `recommend` int(4) NOT NULL DEFAULT '1' COMMENT '是否推荐', `title_url` varchar(200) NOT NULL COMMENT '博文地址', `create_time` int(10) NOT NULL COMMENT '创建时间', `update_time` int(10) NOT NULL COMMENT '更新时间', PRIMARY KEY (`id`), KEY `cat_id` (`cat_id`), CONSTRAINT `blog_article_ibfk_1` FOREIGN KEY (`cat_id`) REFERENCES `blog_category` (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8MySQL 返回: #1215 - Cannot add foreign key constraint

问题解答

回答1:

导入数据库文件报错 #1215 - Cannot add foreign key constraint

报错百度一下就有, 应该是数据类型或者约束不同的原因

相关文章: