[GLLUG] use SQL reserved words as field names

Caleb Cushing xenoterracide at gmail.com
Tue May 23 22:47:33 EDT 2006


I'm trying to create a field named show inside of a table. however it gives
me a syntax error because it's a reserved word. I'm using mysql 4.1.  No
frontend. I've checked this
http://dev.mysql.com/doc/refman/4.1/en/reserved-words.html but it doesn't
seem to help. I changed the name to shows and it works so I'm sure it has
something to do with it being a keyword. This isn't THAT important but I
feel it's something I should know how to do or at least know why it won't
work.


mysql> create table Races
    -> (track CHAR(30) NOT NULL,
    -> racedate DATE NOT NULL,
    -> race INTEGER NOT NULL CHECK (race > 0),
    -> win CHAR(30) NOT NULL REFERENCES Horses(horsename),
    -> place CHAR(30) NOT NULL REFERENCES Horses (horsename),
    -> show CHAR(30) NOT NULL REFERENCES Horses(horsename),
    -> PRIMARY KEY (track, racedate, race));
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 'show CHAR(30) NOT NULL REFERENCES Horses(horsename),
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.egr.msu.edu/mailman/public/linux-user/attachments/20060523/35838c1e/attachment.html


More information about the linux-user mailing list