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 SQL statements. Reserved words, on the other hand, do not have special significance now, but they probably will in a future release. Note that these words can be used as identifiers on most platforms, but they shouldn’t be. For example, the word “SELECT” is a keyword and should not be used as a table name. To emphasize the fact that keywords should not be used as identifiers but nevertheless could be, the SQL standard calls them “nonreserved keywords.”

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 and keywords are not always words used in SQL statements; they may also be words commonly associated with database technology. For example, CASCADE is used to describe data manipulations that allow their actions, such as a delete or update operation, to “flow down,” or cascade, to any subordinate tables. Reserved words and keywords are widely published so that programmers will not use them as identifiers that will, either now or at some later revision, cause a problem.

SQL3 specifies its own list of ...

Get SQL in a Nutshell, 3rd 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.