Bug #26961 Reserved Keyword Problem
Submitted: 8 Mar 2007 15:51 Modified: 8 Mar 2007 15:59
Reporter: Richard Pereira Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Parser Severity:S3 (Non-critical)
Version:5.0 OS:Windows (Windows)
Assigned to: CPU Architecture:Any

[8 Mar 2007 15:51] Richard Pereira
Description:
Create table Order (id int(11) NOT NULL auto_increment, PRIMARY KEY (id) );

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 'Order
 (id int(11) NOT NULL auto_increment, PRIMARY KEY (id) )' at line 1

If the tablename is changed to 'Orders', for example, it works.

How to repeat:
Execute : Create table Order (id int(11) NOT NULL auto_increment, PRIMARY KEY (id) );
[8 Mar 2007 15:59] MySQL Verification Team
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://dev.mysql.com/doc/ and the instructions on
how to report a bug at http://bugs.mysql.com/how-to-report.php

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9 to server version: 5.0.27-community-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use db1
Database changed
mysql> Create table Order (id int(11) NOT NULL auto_increment, PRIMARY KEY
    -> (id) );
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL s
the right syntax to use near 'Order (id int(11) NOT NULL auto_increment, PRIMARY KEY
(id) )' at line 1
mysql> Create table `Order` (id int(11) NOT NULL auto_increment, PRIMARY KEY
    -> (id) );
Query OK, 0 rows affected (0.48 sec)

mysql>
[8 Mar 2007 16:09] Paul DuBois
The behavior is expected. ORDER is a reserved word.
You can quote it to use it as an identifier, as described
here:

http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html