2010-09-20 22:08:53 +02:00
|
|
|
<!-- doc/src/sgml/keywords.sgml -->
|
2001-11-02 20:13:09 +01:00
|
|
|
|
2001-01-06 12:58:56 +01:00
|
|
|
<appendix id="sql-keywords-appendix">
|
|
|
|
<title><acronym>SQL</acronym> Key Words</title>
|
|
|
|
|
2001-05-13 00:51:36 +02:00
|
|
|
<indexterm zone="sql-keywords-appendix">
|
2003-08-31 19:32:24 +02:00
|
|
|
<primary>key word</primary>
|
2001-05-13 00:51:36 +02:00
|
|
|
<secondary>list of</secondary>
|
|
|
|
</indexterm>
|
|
|
|
|
2001-01-06 12:58:56 +01:00
|
|
|
<para>
|
2017-11-23 15:39:47 +01:00
|
|
|
<xref linkend="keywords-table"/> lists all tokens that are key words
|
2001-01-06 12:58:56 +01:00
|
|
|
in the SQL standard and in <productname>PostgreSQL</productname>
|
|
|
|
&version;. Background information can be found in <xref
|
2017-11-23 15:39:47 +01:00
|
|
|
linkend="sql-syntax-identifiers"/>.
|
2012-05-24 19:06:25 +02:00
|
|
|
(For space reasons, only the latest two versions of the SQL standard, and
|
|
|
|
SQL-92 for historical comparison, are included. The differences between
|
|
|
|
those and the other intermediate standard versions are small.)
|
2001-01-06 12:58:56 +01:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
SQL distinguishes between <firstterm>reserved</firstterm> and
|
2002-01-08 16:38:42 +01:00
|
|
|
<firstterm>non-reserved</firstterm> key words. According to the standard,
|
2010-11-23 21:27:50 +01:00
|
|
|
reserved key words
|
2001-01-06 12:58:56 +01:00
|
|
|
are the only real key words; they are never allowed as identifiers.
|
|
|
|
Non-reserved key words only have a special meaning in particular
|
|
|
|
contexts and can be used as identifiers in other contexts. Most
|
|
|
|
non-reserved key words are actually the names of built-in tables
|
2002-01-08 16:38:42 +01:00
|
|
|
and functions specified by SQL. The concept of non-reserved key
|
2001-01-06 12:58:56 +01:00
|
|
|
words essentially only exists to declare that some predefined meaning
|
|
|
|
is attached to a word in some contexts.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
In the <productname>PostgreSQL</productname> parser life is a bit
|
|
|
|
more complicated. There are several different classes of tokens
|
|
|
|
ranging from those that can never be used as an identifier to those
|
|
|
|
that have absolutely no special status in the parser as compared to
|
|
|
|
an ordinary identifier. (The latter is usually the case for
|
2002-01-08 16:38:42 +01:00
|
|
|
functions specified by SQL.) Even reserved key words are not
|
2001-01-06 12:58:56 +01:00
|
|
|
completely reserved in <productname>PostgreSQL</productname>, but
|
2002-01-08 16:38:42 +01:00
|
|
|
can be used as column labels (for example, <literal>SELECT 55 AS
|
2001-01-06 12:58:56 +01:00
|
|
|
CHECK</literal>, even though <token>CHECK</token> is a reserved key
|
|
|
|
word).
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2017-11-23 15:39:47 +01:00
|
|
|
In <xref linkend="keywords-table"/> in the column for
|
2001-01-06 12:58:56 +01:00
|
|
|
<productname>PostgreSQL</productname> we classify as
|
|
|
|
<quote>non-reserved</quote> those key words that are explicitly
|
2006-12-30 22:21:56 +01:00
|
|
|
known to the parser but are allowed as column or table names.
|
|
|
|
Some key words that are otherwise
|
2001-11-17 14:27:16 +01:00
|
|
|
non-reserved cannot be used as function or data type names and are
|
2002-01-08 16:38:42 +01:00
|
|
|
marked accordingly. (Most of these words represent built-in
|
2001-11-17 14:27:16 +01:00
|
|
|
functions or data types with special syntax. The function or type
|
|
|
|
is still available but it cannot be redefined by the user.) Labeled
|
2006-12-30 22:21:56 +01:00
|
|
|
<quote>reserved</quote> are those tokens that are not allowed as
|
|
|
|
column or table names. Some reserved key words are
|
|
|
|
allowable as names for functions or data types; this is also shown in the
|
|
|
|
table. If not so marked, a reserved key word is only allowed as an
|
|
|
|
<quote>AS</quote> column label name.
|
2001-11-17 14:27:16 +01:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
As a general rule, if you get spurious parser errors for commands
|
|
|
|
that contain any of the listed key words as an identifier you should
|
|
|
|
try to quote the identifier to see if the problem goes away.
|
2001-01-06 12:58:56 +01:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
It is important to understand before studying <xref
|
2017-11-23 15:39:47 +01:00
|
|
|
linkend="keywords-table"/> that the fact that a key word is not
|
2001-01-06 12:58:56 +01:00
|
|
|
reserved in <productname>PostgreSQL</productname> does not mean that
|
|
|
|
the feature related to the word is not implemented. Conversely, the
|
|
|
|
presence of a key word does not indicate the existence of a feature.
|
|
|
|
</para>
|
|
|
|
|
2019-05-07 15:29:39 +02:00
|
|
|
&keywords-table;
|
2001-01-06 12:58:56 +01:00
|
|
|
|
|
|
|
</appendix>
|