国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

mysql建表報錯,查手冊看不懂,求解?

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

問題描述

mysql建表報錯,查手冊看不懂,求解?

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;

報錯: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

問題解答

回答1:

創建帶索引的數據庫表需要為表名和屬性添加反單引號,并且你當前的primary key的位置需要調整一下:

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其他的屬性和表名不加反單引號也可以,即這樣也是可以的:

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創建和刪除表

回答2:

primary_key聲明的不對,樓上解

主站蜘蛛池模板: 高碑店市| 麻栗坡县| 图木舒克市| 壶关县| 会理县| 莫力| 神木县| 晋城| 中超| 五寨县| 旅游| 恩施市| 丰顺县| 抚松县| 车致| 易门县| 祁连县| 普陀区| 余庆县| 望奎县| 玉门市| 永新县| 四川省| 拜城县| 板桥市| 上饶市| 当阳市| 宝山区| 亚东县| 寿阳县| 上蔡县| 合作市| 炉霍县| 双城市| 吕梁市| 南溪县| 达拉特旗| 布拖县| 万源市| 正镶白旗| 剑河县|