mysql数据库创建带横杠的数据库名

来源:互联网 发布:mac升级后能退回吗 编辑:程序博客网 时间:2024/06/07 06:59
mysql> create database d-d;

ERROR 1064 (42000): 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 '-d' at line 1


1064报错:该错误一般出现在表名或者字段名设计过程中出现了mysql关键字导致的。问题确定是数据库名字的错误,我把横杠去掉以后就可以。


尝试:

create database [d-d];

create database 'd-d';

create database ”d-d“;

create database d\-d;

均报错:
ERROR 1064 (42000): 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 '[d-d]' at line 1

解决:create database `d-d`;    加反引号


mysql> create database `d-d`;
Query OK, 1 row affected (0.00 sec)

原创粉丝点击