登录

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

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

# PHP
Silvano Silvano 1234 天前 1407 次浏览

全部回复(1) 我要回复

  • 1900

    19002020-12-08 09:52:15

    image.png

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

    回复
    0
  • 取消 回复 发送