When I use the MySQL client to create database, if I type below command:
create database nice-day;
Then it tells me that:
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 '-day' at line 1
But when I use phpAdmin tool, I can create the database named nice-day. What is the problem?
The
-character is not considered to be part of an identifier in SQL, so the database name must be quoted:In general, though, it is advisable to use underscores (
_) instead of dashes in database names to avoid this issue.