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

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 1mysql


1064报错:该错误通常出如今表名或者字段名设计过程当中出现了mysql关键字致使的。问题肯定是数据库名字的错误,我把横杠去掉之后就能够。sql


尝试:数据库

create database [d-d];spa

create database 'd-d';设计

create database ”d-d“;server

create database d\-d;io

均报错:
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
error

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


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