MySQL 语句创建表失败 & You have an erro
2019-01-17 本文已影响0人
南窗云
报错信息
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 '' at line 1
![](https://img.haomeiwen.com/i2849271/fe1eda876506f9b7.png)
解决问题
原来语句:
CREATE TABLE tb_area (
area_id int(2) NOT NULL auto_increment,
area_name varchar(200) NOT NULL,
priority int(2) NOT NULL DEFAULT'0',
create_time datetime DEFAULT NULL,
last_edit_time datetime DEFAULT NULL,
PRIMARY KEY(area_id),
UNIQUE KEY UK_AREA(area_name)
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
将字段名和表名,添加反引号 ( 键盘左上角 ),而不是单引号,即可
![](https://img.haomeiwen.com/i2849271/fbeb3228a1d0e5a3.png)
修改语句
CREATE TABLE `tb_area`(
`area_id` int(2) NOT NULL AUTO_INCREMENT,
`area_name` varchar(200) NOT NULL,
`priority` int(2) NOT NULL DEFAULT 0,
`create_time` datetime DEFAULT NULL,
`last_edit_time` datetime DEFAULT NULL,
PRIMARY KEY(`area_id`),
UNIQUE KEY `UK_AREA`(`area_name`)
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
上述语句在终端输入,是可以成功运行的,
但是在 Sequel Pro 客户端运行,就一直在运行中...运行中...运行中...
![](https://img.haomeiwen.com/i2849271/e1e2482d4dbf2bae.png)
事实证明,是客户端有问题!
是时候找一个好用且功能强大的客户端了!《 DataGrip 自由使用步骤 》