How can i drop a database containing the "-" symbol?
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>
First, launch the MySQL workbench and log in to the MySQL Server. Second, right-click the database that you want to remove, for example, testdb2 and choose the Drop Schema... option. Third, MySQL Workbench displays a dialog to confirm the deletion.
Dropping a database deletes the database from an instance of SQL Server and deletes the physical disk files used by the database. If the database or any one of its files is offline when it is dropped, the disk files are not deleted. These files can be deleted manually by using Windows Explorer.
IF EXISTS is used to prevent an error from occurring if the database does not exist. If the default database is dropped, the default database is unset (the DATABASE() function returns NULL ). If you use DROP DATABASE on a symbolically linked database, both the link and the original database are deleted.
You can quote identifiers (for example table and column names) with backticks:
drop database `vms-0.1.0`
See the documentation for more details: Schema Object Names.
The identifier quote character is the backtick ("`"):
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With