MYSQL中ERROR 1005 (HY000): Can't create table 错误

今天建立一个MYSQL数据库时遇到的一个小问题:web

create table booktype
(
   btid   int(5) unsigned zerofill auto_increment not null primary key,
   btname varchar(100) not null unique,
   btnote text
);数据库

create table books
(
   bid int(5) unsigned zerofill auto_increment not null primary key,
   bname char(30) not null,
   isbn char(50) not null,
   author char(30) not null,
   press   text,
   summary text,
   bcount int not null default 0,
   btid   int,
   foreign key(btid) references booktype(btid) 
);spa

出现的报错:orm

ERROR 1005 (HY000): Can't create table '.\bookdata\books.frm' (errno: 150)ci

主要问题是:rem

foreign key(btid) references booktype(btid) 中books表的 btid   是int和booktype表中的btid设置的关联字段类型不匹配,books表中btid改正成:btid   int(5) unsigned zerofill ,就不会报错了,建立表和修改表地时候经常一步小小就忘记了这个.it

相关文章
相关标签/搜索