16

Just trying out ubuntu server on my pc and have been testing some commands including mysql. I'm not sure why phpMyAdmin permitted me to create a database like this 'testing?db'. I'm trying to drop this database via SSH but I get this error:

mysql> show databases
    -> ;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| phpmyadmin         |
| testing?db         |
| testing_db         |
| wp                 |
+--------------------+
6 rows in set (0.00 sec)

mysql> DROP DATABASE testing?db;
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 '?db' at line 1
mysql>

I tried creating a database with a '?' in it and it also gives me syntax error. via ssh. so how do I remove this database?

Kara
  • 6,115
  • 16
  • 50
  • 57
hugseirvak
  • 315
  • 1
  • 2
  • 11

1 Answers1

55

Try:

DROP DATABASE `testing?db`;
mvds
  • 45,755
  • 8
  • 102
  • 111
  • 2
    yes, you can escape your table/fields name with a ` character – Yanick Rochon Mar 27 '11 at 03:14
  • 1
    I was going to post the same thing. Nice. – SQLMason Mar 27 '11 at 03:18
  • 1
    It's called the backtick, present on any keyboard, but not in a fixed location. Look somewhere to the top or bottom left. – mvds Mar 27 '11 at 13:04
  • oh thanks! :) i've been using the computer for as long as i can remember but never noticed this `backtick` character on my keyboard. – hugseirvak Mar 28 '11 at 04:29
  • Isn't it also the "left single quotation mark" ? http://www.fileformat.info/info/unicode/char/2018/index.htm – Jasmine Sep 14 '17 at 23:13
  • 1
    @Jasmine I think not, the lsqo is a quotation character, while the backtick is actually an accent (http://www.fileformat.info/info/unicode/char/0060/index.htm) – mvds Sep 15 '17 at 20:34