国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

mysql建表報(bào)錯(cuò),查手冊(cè)看不懂,求解?
僅有的幸福
僅有的幸福 2017-06-06 09:52:09
0
2
809

mysql建表報(bào)錯(cuò),查手冊(cè)看不懂,求解?

create table abc(
   id int unsigned  primary_key auto_increment,
   usename char(20) not null default '',
   gender char(1) not null default '',
   weight tinyint unsigned not null default 0, 
   birth date not null default 0,
   salary decimal(8,2) not null default '000000.00',
   lastlogin timestamp not null default 0,
   intro varchar(1500) not null default '',
)engine myisam charset=utf8;

錯(cuò)誤回報(bào):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 'primary_key auto_increment,username char(20) not'' null ault not' line 3

僅有的幸福
僅有的幸福

全部回覆(2)
伊謝爾倫

建立帶有索引的資料庫表需要為表名和屬性添加反單引號(hào),並且你目前的primary key的位置需要調(diào)整一下:

create table `abc`(
   `id` int unsigned auto_increment,
   `usename` char(20) not null default '',
   `gender` char(1) not null default '',
   `weight` tinyint unsigned not null default 0, 
   `birth` date not null default 0,
   `salary` decimal(8,2) not null default '000000.00',
   `lastlogin` timestamp not null default 0,
   `intro` varchar(1500) not null default '',
   primary key (`id`)
)engine myisam charset=utf8;

我剛剛試了一下,除了primary key其他的屬性和表名不加反單引號(hào)也可以,即這樣也是可以的:

create table abc(
   id int unsigned auto_increment,
   usename char(20) not null default '',
   gender char(1) not null default '',
   weight tinyint unsigned not null default 0, 
   birth date not null default 0,
   salary decimal(8,2) not null default '000000.00',
   lastlogin timestamp not null default 0,
   intro varchar(1500) not null default '',
   primary key (`id`)
)engine myisam charset=utf8;

參考:mysql建立和刪除表

Peter_Zhu

primary_key聲明的不對(duì),樓上解

最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板