2011-10-01 4 views
8

Come posso eliminare un database contenente il simbolo "-"?Impossibile eliminare il database a causa di carattere non valido

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> 

risposta

17

Si può citare identificatori (ad esempio tavolo e nomi di colonne) con apici inversi:

drop database `vms-0.1.0` 

vedere la documentazione per maggiori dettagli: Schema Object Names.

Il carattere identificativo citazione è l'apice inverso ("`"):