久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

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

瀏覽:193日期:2022-06-11 16:56:55

問(wèn)題描述

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;

報(bào)錯(cuò):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 default ’’,gender c’ at line 3

問(wèn)題解答

回答1:

創(chuàng)建帶索引的數(shù)據(jù)庫(kù)表需要為表名和屬性添加反單引號(hào),并且你當(dāng)前的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創(chuàng)建和刪除表

回答2:

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

主站蜘蛛池模板: 拜泉县| 鄢陵县| 太仆寺旗| 清新县| 鹤庆县| 全椒县| 广饶县| 洞头县| 临朐县| 武川县| 甘谷县| 上思县| 文安县| 定安县| 石景山区| 门源| 来安县| 郑州市| 黔南| 邯郸市| 福鼎市| 浦北县| 奉节县| 台东县| 辽阳县| 肥城市| 新干县| 肥东县| 巢湖市| 鄂尔多斯市| 庆云县| 峡江县| 涿鹿县| 图木舒克市| 麻栗坡县| 五指山市| 苏州市| 嘉峪关市| 韶山市| 靖江市| 资源县|