2011-10-01 84 views
8

如何删除包含“ - ”符号的数据库?由于非法字符而无法删除数据库

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> 

回答

17

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

drop database `vms-0.1.0` 

详情请参见文档:Schema Object Names

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