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?

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.

  • 1
    Thanks for the input, I had the feeling I was missing something. – Rui F Ribeiro Jul 6 '17 at 8:15
  • 1
    This catches a lot of developers, even experienced ones. – Tigger Jul 6 '17 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.