Bug #9783 Unable to create a new database with a name containing a hyphen

Submitted: 9 Apr 2005 14:58 Modified: 9 Apr 2005 15:21
Reporter: David Leangen Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.1.10 and 4.1.11 OS:Linux (Linux RH Fedora 2)
Assigned to: CPU Architecture:Any

[9 Apr 2005 14:58] David Leangen
Description:
According to the documentation on the mySQL website, for a database name:

  Any character that is allowed in a directory name, except '/', '\', or '.'

Ref: http://dev.mysql.com/doc/mysql/en/legal-names.html

However, when trying to create a database with the "-" character, I get an error 1064.

For example:

mysql> create database some-name;
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 '-name' at line 1

How to repeat:
Start the mysql administration program and attempt to create a new database with a name containing a '-'.

Suggested fix:
No idea.
[9 Apr 2005 15:05] Jim Winstead
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.mysql.com/documentation/ and the instructions on
how to report a bug at http://bugs.mysql.com/how-to-report.php

Additional info:

From a little further down on the page:

An identifier may be quoted or unquoted. If an identifier is a reserved  word or contains special characters, you must quote it whenever you  refer to it. For a list of reserved words, see Section 9.6, “Treatment of Reserved Words in MySQL”. Special characters are those outside the set of alphanumeric characters from  the current character set, '_', and '$'.

You need to quote a name with a hyphen in it, like:

create database `some-name`;
[9 Apr 2005 15:09] David Leangen
Thank you for your VERY fast reply!

Actually, I did try quoting it.

Here is an example:

mysql> create database 'some-name';
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 ''some-name'' at line 1
[9 Apr 2005 15:21] Jim Winstead
A value quoted with single-quotes is a string, not an identifier.

Identifier quoting is explained at http://dev.mysql.com/doc/mysql/en/legal-names.html, with examples.
[9 Apr 2005 15:24] David Leangen
Ah, indeed! That works fine.

Sorry for wasting bandwidth. Thank you again for your very prompt reply and helpful service!!

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.040 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.