用navicat for mysql的命令行建表时出现1064
createtableorder->(idint(10)unsignednotnullauto_increment,->bookidint(10)unsignednotn...
create table order
-> (id int(10) unsigned not null auto_increment,
-> bookid int(10) unsigned not null default '0',
-> userid int(10) unsigned not null default '0',
-> number tinyint(3) unsigned not null default '0',
-> address varchar(128) not null default '',
-> postcode varchar(6) not null default '',
-> orderdate datetime not null default '0000-00-00 00:00:00',
-> status tinyint(3) unsigned zerofill not null default '000',
-> primary key(id),
-> key fk_order_1 (bookid),
-> key fk_order_2 (userid),
-> constraint fk_order_1 foreign key (bookid) references bookinfo (id),
-> constraint fk_order_2 foreign key (userid) references userinfo (id))
-> ;
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'create table order
(id int(10) unsigned not null auto_increment,
bookid ' at line 3 展开
-> (id int(10) unsigned not null auto_increment,
-> bookid int(10) unsigned not null default '0',
-> userid int(10) unsigned not null default '0',
-> number tinyint(3) unsigned not null default '0',
-> address varchar(128) not null default '',
-> postcode varchar(6) not null default '',
-> orderdate datetime not null default '0000-00-00 00:00:00',
-> status tinyint(3) unsigned zerofill not null default '000',
-> primary key(id),
-> key fk_order_1 (bookid),
-> key fk_order_2 (userid),
-> constraint fk_order_1 foreign key (bookid) references bookinfo (id),
-> constraint fk_order_2 foreign key (userid) references userinfo (id))
-> ;
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'create table order
(id int(10) unsigned not null auto_increment,
bookid ' at line 3 展开
1个回答
展开全部
order在mysql中是关键字,表名order会引起歧义,实在要取这个名字可加反引号`order`;
另外id设置为自增则需将它设置为一个key,所以你这里应该在这个位置就加上primary key;
create table `order`
(id int(10) unsigned not null auto_increment primary key,
bookid int(10) unsigned not null default '0'
另外id设置为自增则需将它设置为一个key,所以你这里应该在这个位置就加上primary key;
create table `order`
(id int(10) unsigned not null auto_increment primary key,
bookid int(10) unsigned not null default '0'
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询