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?

1

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

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 (“`”):

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.