Bug #31969 cannot access column named 'usage'
Submitted: 30 Oct 2007 21:50 Modified: 30 Oct 2007 22:29
Reporter: cary sweet Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Parser Severity:S2 (Serious)
Version:5.0.45 OS:Other (Mac OSX server)
Assigned to: CPU Architecture:Any
Tags: column name, Illegal

[30 Oct 2007 21:50] cary sweet
Description:
Insert into table is not accepted.  I am trying to find a list of all invalid column names, but can only find a small list of about 4.  Not to mention that if the table is created, then the column name should be valid and thus accepted on any query.

How to repeat:
Migrated DB from Oracle to MySql.
Try to run system against MySql

Query that fails:
INSERT INTO tablename ( id, 
usage,
columnname3 )
VALUES ( 1, '', '')

Error msg:
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 'usage,
columnname3 )
VALUES ( 1, '', '')' at line 3
[30 Oct 2007 22:14] Paul DuBois
USAGE is a reserved word:

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

To use it as an identifier, you can quote it as `usage`, as described here:

http://dev.mysql.com/doc/refman/5.0/en/identifiers.html
[30 Oct 2007 22:29] cary sweet
I thought that I read somewhere that keywords are not allowed as column/table names.  I guess that should be qualified to include quoted identifiers.  I noticed that our database does not have the SQL Mode ANSI_QUOTES enabled.  Should not be a problem getting it all in place though.  Thanks for the info.