You are Here: FAQ ->Scripting and Programming Languages->MySQL Database->Article #18


Reserved Words in MySQL


MySQL has a multitude of functions, for some of which certain words are reserved. The best known are "CREATE", "SELECT", "UPDATE" and "DROP". The reserved words are used as commands in MySQL for performing database operations. These commands are used to create, change or delete databases and datasets.

To avoid complication, please do not use any reserved words in your table, column or field names.

There is a different list of reserved words for each version of MySQL due to the introduction of new functions. The list of reserved words is backwards compatible. In other words, the terms that were reserved in MySQL 4.0 are still reserved in the current release of MySQL.

The following words are reserved and should not be used as table or field names.

Reserved words in MySQL 4.1 and above:

ASENSITIVE
CALL
CONDITION
CONTINUE
CURSOR
DECLARE
DETERMINISTIC
EACH
ELSEIF
EXIT
FETCH
INOUT
INSENSITIVE
ITERATE
LEAVE
LOOP
MODIFIES
OUT
READS
RELEASE
REPEAT
RETURN
SCHEMA
SCHEMAS
SENSITIVE
SPECIFIC
SQL
SQLEXCEPTION
SQLSTATE
SQLWARNING
TRIGGER
UNDO
WHILE

Reserved words in MySQL 5.1 and above:

ACCESSIBLE
LINEAR
MASTER_SSL_VERIFY_SERVER_CERT
RANGE
READ_ONLY
READ_WRITE

If you wish to use any of these reserved words in your field names, it is necessary to escape them using quotation marks or include the table name.

Example of the use of the reserved word "RANGE":
Incorrect:
SELECT range FROM tablename;

Correct using quotation marks:
SELECT `range` FROM tablename;

Correct using the table name:
SELECT tablename.range FROM tablename;


For further information, see:
http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html


Print Article
How useful was this article?
(From 5 = Very Useful to 1 = Not useful at all):
1 2 3 4 5