12

如何删除包含“-”符号的数据库?

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| vms01              |
| vms-0.1.0          |
+--------------------+
4 rows in set (0.00 sec)

mysql> drop database vms-0.1.0;
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 n
    ear '-0.1.0' at line 1
    mysql>
4

1 回答 1

34

您可以使用反引号引用标识符(例如表名和列名):

drop database `vms-0.1.0`

有关更多详细信息,请参阅文档:架构对象名称

标识符引号字符是反引号(“`”):

于 2011-10-01T06:39:28.173 回答