1

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?

Mike Aski
  • 9,180
  • 4
  • 46
  • 63
DanielDing
  • 13
  • 3
  • you should not use - instead use _ see the link http://stackoverflow.com/questions/7899200/is-there-a-naming-convention-for-mysql – vidyadhar Jan 19 '13 at 06:21

2 Answers2

2

The - character is not considered to be part of an identifier in SQL, so the database name must be quoted:

CREATE DATABASE `nice-day`

In general, though, it is advisable to use underscores (_) instead of dashes in database names to avoid this issue.

0

Please use backticks "`" (the key before the 1 on a standard US 101 keyboard).

as per http://dev.mysql.com/doc/refman/5.0/en/identifiers.html

    The identifier quote character is the backtick (“`”):
DaveStSomeWhere
  • 2,475
  • 2
  • 22
  • 19