2011-10-01 52 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

標識符引號字符是倒引號( 「`」):