开发者社区> 问答> 正文

mysql5.7 创建表外键失败 求看下!!!! 折磨我一天了??报错

创建外键一直失败 ,,,,,难受死了。。。。。

还有  这个版块是可以发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

展开
收起
爱吃鱼的程序员 2020-06-06 16:15:53 553 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB
                        <p>Function 'ngram' is not defined</p>
    
                    
    
                        <p>和外键定义没关系,你的全文检索定义有问题</p>
    
                    
    
                            FULLTEXT (title,content) WITH PARSER ngram 
    

    不太理解,请问是因为innodb引擎的原因吗?

                        <p>你可以先建表,然后再建全文检索, 要根据你生产环境的mysql版本为准,都有差异的</p>
    
    2020-06-06 16:16:13
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
搭建电商项目架构连接MySQL 立即下载
搭建4层电商项目架构,实战连接MySQL 立即下载
PolarDB MySQL引擎重磅功能及产品能力盛大发布 立即下载

相关镜像