Deleting MySQL database with a "-" in the name

Rui F Ribeiro

One member of the dev team managed to create one databases with a "-" in the name with a remote graphical interface (and I think the second one is a legacy DB).

I am trying to remove both of them with the

DROP DATABASE "dbname-a";

command inside the mysql command line interface, however I am getting back the error:

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 near '"dbname-a"' at line 1

I tried using the db name with and without "", and also inside ' '. all variations presented the same syntax error.

What to do?

Tigger

I believe the correct way to do this would be with backtick quoting. For example:

DROP DATABASE `dbname-a`

This true for MySQL reserved keyword as well. Lots more info on this Stack Overflow post - When to use single quotes, double quotes, and backticks in MySQL.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

MySQL database name with illegal characters

From Dev

Deleting MongoDB database and collections

From Dev

Deleting files with ^? in their name

From Dev

Get the connected mysql database name (JDBC)

From Dev

Which is better? - USE DATABASE Vs DATABASE.TABLE_NAME in MySQL

From Dev

Deleting a stored procedure in the database

From Dev

how to parse mysql database name from database_url

From Dev

Change MySQL stored procedure 'Database Collation' name

From Dev

Deleting a ROW from MySQL database using MySQLi

From Dev

How to search a column name from a MySQL database?

From Dev

Deleting nodes in a database tree

From Dev

Deleting row in database

From Dev

Conditionally deleting rows in MySQL Database

From Dev

Add multiple inputs with same name to mysql database

From Dev

Why scheduled event is not deleting data from mysql database

From Dev

Deleting mysql database row

From Dev

Which is better? - USE DATABASE Vs DATABASE.TABLE_NAME in MySQL

From Dev

Deleting a tuple from Database

From Dev

Deleting database records MVC

From Dev

Restoring MySQL database with different name on cPanel

From Dev

Openshift - get domain name for MySQL database

From Dev

Deleting row in database

From Dev

Post optimization needed after deleting rows in a MYSQL Database

From Dev

How to do a Confirmation popup for deleting of MySQL database entry?

From Dev

Issue with connecting JSP page to local MySQL database: wrong Database name

From Dev

Database name as variable in MySQL query

From Dev

Deleting a Database

From Dev

Deleting user from database in Spark Framework and Thymeleaf with MySQL

From Dev

how to insert file name into mysql database

Related Related

HotTag

Archive