創(chuàng)建外鍵一直失敗 ,,,,,難受死了。。。。。
還有 這個版塊是可以發(fā)mysql的吧 我這還迷迷糊糊的。。。。create table trkr_admin( id tinyint unsigned not null auto_increment primary key comment '管理員ID編號', name CHAR(30) not null default '' comment '管理員賬號',
cname CHAR(30) not null default '' comment '管理員昵稱', password char(32) not null default '' comment '管理員密碼', status tinyint not null default '1' comment '賬號狀態(tài) 1開啟 2關(guān)閉', UNIQUE(name), UNIQUE(cname), index(name)
)engine=InnoDB charset=utf8mb4;create table trkr_article( id int unsigned not null auto_increment primary key comment '文章ID編號',
title char(20) not null default '' comment '文章標(biāo)題名稱', content varchar(16000) not null default ' ' comment '文章的內(nèi)容',
bind_adminname_id tinyint unsigned not null comment '發(fā)表文章的作者外鍵',
FOREIGN KEY(bind_adminname_id) REFERENCES trkr_admin(id),
FULLTEXT (title,content) WITH PARSER ngram
)engine=InnoDB charset=utf8mb4;報錯提示:ERROR 1215 (HY000): Cannot add foreign key constraint
2 回答

慕婉清6462132
TA貢獻(xiàn)1804條經(jīng)驗 獲得超2個贊
CREATE TABLE `trkr_admin` ( `id` TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '管理員ID編號', `name` CHAR(30) NOT NULL DEFAULT '' COMMENT '管理員賬號', `cname` CHAR(30) NOT NULL DEFAULT '' COMMENT '管理員昵稱', `password` CHAR(32) NOT NULL DEFAULT '' COMMENT '管理員密碼', `status` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '賬號狀態(tài) 1開啟 2關(guān)閉', PRIMARY KEY (`id`), UNIQUE INDEX `name` (`name`), UNIQUE INDEX `cname` (`cname`) )COLLATE='utf8mb4_general_ci'ENGINE=InnoDB;CREATE TABLE `trkr_article` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '文章ID編號', `title` CHAR(20) NOT NULL DEFAULT '' COMMENT '文章標(biāo)題名稱', `content` VARCHAR(16000) NOT NULL DEFAULT ' ' COMMENT '文章的內(nèi)容', `bind_adminname_id` TINYINT(3) UNSIGNED NOT NULL COMMENT '發(fā)表文章的作者外鍵', PRIMARY KEY (`id`), INDEX `bind_adminname_id` (`bind_adminname_id`), CONSTRAINT `trkr_article_ibfk_1` FOREIGN KEY (`bind_adminname_id`) REFERENCES `trkr_admin` (`id`), FULLTEXT (title,content) WITH PARSER ngram )COLLATE='utf8mb4_general_ci'ENGINE=InnoDB;
看樣子像是子表字段索引沒建?或者你那個解析器ngram執(zhí)行有沒問題
添加回答
舉報
0/150
提交
取消