Keywords and Reserved Words

Just as certain symbols have special meaning and functionality within SQL, certain words and phrases have special significance. SQL keywords are words whose meanings are so closely tied to the operation of the RDBMS that they should not be used for any other purpose; generally, they are words used in a SQL statement. (Note that they can be used as an identifier on most platforms, but they shouldn’t be.) For example, the word “SELECT” is a reserved word and should not be used as a table name.

Tip

It is generally a good idea to avoid naming columns or tables after a keyword that occurs in any major platform, because database applications are frequently converted from one platform to another.

Reserved words, on the other hand, do not have special significance now, but they probably will in a future release. To emphasize the fact that keywords should not be used as an identifier, but nevertheless could be, the SQL standard calls them “nonreserved keywords.” Reserved words and keywords are not always words used in SQL statements, but may be words commonly associated with database technology. For example, CASCADE is used to describe data manipulations that allow their action, such as a delete or update, to “flow down,” or cascade, to any subordinant tables. Reserved words and keywords are widely published so that programmers will not use them as identifiers that will, at some later revision, cause a problem.

SQL2003 specifies its own list of reserved words and ...

Get SQL in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.