首頁  >  問答  >  主體

導入資料庫檔案報錯 #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_`update_` int(10ate Ntime NULL COMMENT '更新時間',  PRIMARY KEY (`id`),  KEY `cat_id` (`cat_id`),  CONSTRAINT `blog_article_ibfk_1` FOREIGN KEY (`cat_id`) REFERENCES `blog_categom`( CHARSET=utf8MySQL 回傳: #1215 - Cannot add foreign key constraint

SilvanoSilvano1390 天前1515

全部回覆(1)我來回復

  • 1900

    19002020-12-08 09:52:15

    image.png

    報錯百度一下就有, 應該是資料型別或是約束不同的原因

    回覆
    0
  • 取消回覆