0

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?

2 Answers 2

3

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.

2
  • 1
    Thanks for the input, I had the feeling I was missing something. Jul 6, 2017 at 8:15
  • 1
    This catches a lot of developers, even experienced ones.
    – Tigger
    Jul 6, 2017 at 8:16
0

I ended up having to delete it in the command line, as in:

mysqladmin drop "dbname-a"

From Oracle 5.7 Reference Manual - mysqladmin

drop db_name

Delete the database named db_name and all its tables.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .