创建外键一直失败 ,,,,,难受死了。。。。。
还有 这个版块是可以发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 '账号状态 1开启 2关闭',
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 '文章标题名称',
content varchar(16000) not null default ' ' comment '文章的内容',
bind_adminname_id tinyint unsigned not null comment '发表文章的作者外键',
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
嗯,其实一两天还是蛮常见的,不过当然是越快解决越好了。而且碰到这种问题,最好如果有报错先将报错信息,以及相关代码放上来才方便大家帮你查找问题。关于外键这块,我涉及的也不多(不是不多,而是根本没有实操过,一般都是通过程序控制 sql 。)相关链接