@ -1,4 +1,4 @@
<chapter id="syntax" >
<chapter>
<title>SQL Syntax</title>
<title>SQL Syntax</title>
<sect1>
<sect1>
@ -13,6 +13,7 @@ restricted to appear in only certain contexts. Other key words are
<firstterm>not restricted</firstterm>, which indicates that in certain
<firstterm>not restricted</firstterm>, which indicates that in certain
contexts they
contexts they
have a specific meaning but are not otherwise constrained.
have a specific meaning but are not otherwise constrained.
</para>
<para>
<para>
<productname>Postgres</productname> implements an extended subset of the
<productname>Postgres</productname> implements an extended subset of the
@ -20,15 +21,17 @@ have a specific meaning but are not otherwise constrained.
elements are not as restricted in this implementation as is
elements are not as restricted in this implementation as is
called for in the language standards, in part due
called for in the language standards, in part due
to the extensibility features of <productname>Postgres</productname>.
to the extensibility features of <productname>Postgres</productname>.
</para>
<para>
<para>
Information on <acronym>SQL92</acronym> and <acronym>SQL3</acronym> key words
Information on <acronym>SQL92</acronym> and <acronym>SQL3</acronym> key words
is derived from <xref linkend="DATE97" endterm="DATE97-full">.
is derived from <xref linkend="DATE97" endterm="DATE97">.
</para>
<S ect2>
<s ect2>
<Title>Reserved Key Words</T itle>
<title>Reserved Key Words</t itle>
<P ara>
<p ara>
<acronym>SQL92</acronym> and <acronym>SQL3</acronym> have
<acronym>SQL92</acronym> and <acronym>SQL3</acronym> have
<firstterm>reserved key words</firstterm> which are not allowed
<firstterm>reserved key words</firstterm> which are not allowed
as identifiers and not allowed in any usage other than as fundamental
as identifiers and not allowed in any usage other than as fundamental
@ -37,13 +40,14 @@ tokens in <acronym>SQL</acronym> statements.
which have similar restrictions. In particular, these key words
which have similar restrictions. In particular, these key words
are not allowed as column or table names, though in some cases
are not allowed as column or table names, though in some cases
they are allowed to be column labels (i.e. in AS clauses).
they are allowed to be column labels (i.e. in AS clauses).
</para>
<tip>
<tip>
<para>
<para>
Any string can be specified as an identifier if surrounded by
Any string can be specified as an identifier if surrounded by
double quotes (<quote>like this!</quote>). Some care is required since
double quotes (<quote>like this!</quote>). Some care is required since
such an identifier will be case sensitive
such an identifier will be case sensitive
and will retain embedded whitespace other special characters.
and will retain embedded whitespace other special characters.</para>
</tip>
</tip>
<para>
<para>
@ -66,7 +70,9 @@ SETOF SHOW
UNLISTEN UNTIL
UNLISTEN UNTIL
VACUUM VERBOSE
VACUUM VERBOSE
</programlisting>
</programlisting>
</para>
<para>
The following are <productname>Postgres</productname>
The following are <productname>Postgres</productname>
reserved words which are also <acronym>SQL92</acronym>
reserved words which are also <acronym>SQL92</acronym>
or <acronym>SQL3</acronym> reserved words, and which
or <acronym>SQL3</acronym> reserved words, and which
@ -113,7 +119,9 @@ UNION UNIQUE UPDATE USER USING
VALUES VARCHAR VARYING VIEW
VALUES VARCHAR VARYING VIEW
WHERE WITH WORK
WHERE WITH WORK
</programlisting>
</programlisting>
</para>
<para>
The following are <acronym>SQL92</acronym> reserved key words which
The following are <acronym>SQL92</acronym> reserved key words which
are not <productname>Postgres</productname> reserved key words, but which
are not <productname>Postgres</productname> reserved key words, but which
if used as function names are always translated into the function
if used as function names are always translated into the function
@ -122,7 +130,9 @@ if used as function names are always translated into the function
<programlisting>
<programlisting>
CHAR_LENGTH CHARACTER_LENGTH
CHAR_LENGTH CHARACTER_LENGTH
</programlisting>
</programlisting>
</para>
<para>
The following are <acronym>SQL92</acronym> or <acronym>SQL3</acronym>
The following are <acronym>SQL92</acronym> or <acronym>SQL3</acronym>
reserved key words which
reserved key words which
are not <productname>Postgres</productname> reserved key words, but
are not <productname>Postgres</productname> reserved key words, but
@ -131,6 +141,7 @@ if used as type names are always translated into an alternate, native type:
<programlisting>
<programlisting>
BOOLEAN DOUBLE FLOAT INT INTEGER INTERVAL REAL SMALLINT
BOOLEAN DOUBLE FLOAT INT INTEGER INTERVAL REAL SMALLINT
</programlisting>
</programlisting>
</para>
<para>
<para>
The following are either <acronym>SQL92</acronym>
The following are either <acronym>SQL92</acronym>
@ -146,6 +157,7 @@ Some of these key words represent functions in <acronym>SQL92</acronym>.
These functions are defined in <productname>Postgres</productname>,
These functions are defined in <productname>Postgres</productname>,
but the parser does not consider the names to be key words and they are allowed
but the parser does not consider the names to be key words and they are allowed
in other contexts.
in other contexts.
</para>
</note>
</note>
<programlisting>
<programlisting>
@ -170,11 +182,13 @@ UNKNOWN UPPER USAGE
VALUE
VALUE
WHENEVER WRITE
WHENEVER WRITE
</programlisting>
</programlisting>
</para>
</sect2>
<Sect2>
<s ect2>
<Title>Non-reserved Keywords</T itle>
<title>Non-reserved Keywords</t itle>
<P ara>
<p ara>
<acronym>SQL92</acronym> and <acronym>SQL3</acronym> have
<acronym>SQL92</acronym> and <acronym>SQL3</acronym> have
<firstterm>non-reserved keywords</firstterm> which have
<firstterm>non-reserved keywords</firstterm> which have
a proscribed meaning in the language but which are also allowed
a proscribed meaning in the language but which are also allowed
@ -183,6 +197,7 @@ as identifiers.
which allow similar unrestricted usage.
which allow similar unrestricted usage.
In particular, these keywords
In particular, these keywords
are allowed as column or table names.
are allowed as column or table names.
</para>
<para>
<para>
The following are <productname>Postgres</productname>
The following are <productname>Postgres</productname>
@ -208,6 +223,7 @@ SEQUENCE SERIAL START STATEMENT STDIN STDOUT
TRUSTED
TRUSTED
VALID VERSION
VALID VERSION
</programlisting>
</programlisting>
</para>
<para>
<para>
The following are <productname>Postgres</productname>
The following are <productname>Postgres</productname>
@ -231,6 +247,7 @@ TIME TIMESTAMP TIMEZONE_HOUR TIMEZONE_MINUTE TRIGGER
YEAR
YEAR
ZONE
ZONE
</programlisting>
</programlisting>
</para>
<para>
<para>
The following are <productname>Postgres</productname>
The following are <productname>Postgres</productname>
@ -240,6 +257,7 @@ or <acronym>SQL3</acronym> non-reserved key words:
<programlisting>
<programlisting>
TYPE
TYPE
</programlisting>
</programlisting>
</para>
<para>
<para>
The following are either <acronym>SQL92</acronym>
The following are either <acronym>SQL92</acronym>
@ -268,3 +286,24 @@ SUBCLASS_ORIGIN
TABLE_NAME
TABLE_NAME
UNCOMMITTED UNNAMED
UNCOMMITTED UNNAMED
</programlisting>
</programlisting>
</para>
</sect2>
</sect1>
</chapter>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"./reference.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:"/usr/lib/sgml/CATALOG"
sgml-local-ecat-files:nil
End:
-->