BNF Grammar for ISO/IEC 9075-2:2003 - Database Language SQL (SQL-2003) SQL/Foundation
=====================================================================================
@(#)$Id: sql-2003-2.bnf,v 1.16 2011/07/11 18:00:02 jleffler Exp $
--p
Information taken from the Final Committee Draft (FCD) of ISO/IEC 9075-2:2003.
However, the page numbers and some section titles (9.14 through 9.23,
for example) are from the final standard.
This means there could be other as yet undiagnosed differences between
the final standard and the notation in this document; you were warned!
--/p
--p
The plain text version of this grammar is
--## sql-2003-2.bnf .
--/p
--hr
--h2 Key SQL Statements and Fragments
--/h2
--bl
--li ALTER DOMAIN
--li ALTER TABLE
--li CLOSE cursor
--li Column definition
--li COMMIT WORK
--li CONNECT
--li CREATE ASSERTION
--li CREATE CHARACTER SET
--li CREATE COLLATION
--li CREATE DOMAIN
--li CREATE FUNCTION
--li CREATE PROCEDURE
--li CREATE SCHEMA
--li CREATE TABLE
--li CREATE TRANSLATION
--li CREATE TRIGGER
--li CREATE VIEW
--li Data type
--li DEALLOCATE PREPARE
--li DECLARE cursor
--li DECLARE LOCAL TEMPORARY TABLE
--li DELETE
--li DESCRIBE
--li DESCRIPTOR statements
--li DISCONNECT
--li EXECUTE
--li EXECUTE IMMEDIATE
--li FETCH cursor
--li FROM clause
--li GET DIAGNOSTICS
--li GRANT
--li GROUP BY clause
--li HAVING clause
--li INSERT
--li Literals
--li Keywords
--li MERGE
--li OPEN cursor
--li ORDER BY clause
--li PREPARE
--li REVOKE
--li ROLLBACK WORK
--li SAVEPOINT
--li Search condition
--li SELECT
--li SET CATALOG
--li SET CONNECTION
--li SET CONSTRAINTS
--li SET NAMES
--li SET SCHEMA
--li SET SESSION AUTHORIZATION
--li SET TIME ZONE
--li SET TRANSACTION
--li SQL Client MODULE
--li UPDATE
--li Value expression
--li WHERE clause
--/bl
--hr
--h2 5 Lexical Elements
--/h2
--p
Basic definitions of characters used, tokens, symbols, etc.
Most of this section would normally be handled within the lexical
analyzer rather than in the grammar proper.
Further, the original document does not quote the various single
characters, which makes it hard to process automatically.
--/p
--h3 5.1 (p151)
--/h3
::= ::= | | ::= | ::=
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z
::=
a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r | s | t | u | v | w | x | y | z
::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
::=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| ::= !! See the Syntax Rules.
::= "
::= %
::= &
::= '
::= (
::= )
::= *
::= +
::= ,
::= -
::= .
::= /
::= :
::= ;
::= <
::= =
::= >
::= ?
--p
--i
The trigraphs are new in SQL-2003.
--/i
--/p
::= | ::= | ::= [
::= ??(
::= ]
::= ??)
::= ^
::= _
::= |
::= {
::= }
--hr
--h3 5.2 and (p134)
--/h3
--p
Specifying lexical units (tokens and separators) that participate in SQL language.
--/p
::= | ::=
|
|
|
|
|
|
| ::= ::= [ ... ]
::= |
--p
--i
--small
Previous standard said:
--br
::= |
--/small
--/i
--/p
::= !! See the Syntax Rules.
::= !! See the Syntax Rules.
::= ... ::= K | M | G
::= ::= ...
::= |
--p
--i
--small
The productions for and so on are new in SQL-2003.
--/small
--/i
--/p
::=
U ::= [ UESCAPE ]
::= ...
::= | ::=
|
|
--p
--i
--small
Syntax rule 20: '+xyzw' is equivalent to the Unicode code point specified by
U+xyzw.
--/small
--/i
--/p
::=
--p
--i
--small
Syntax rule 21: '+xyzwrs' is equivalent to the Unicode code point specified by
U+xyzwrs.
--/small
--/i
--/p
--p
--i
--small
NOTE 64: The 6-hexit notation is derived by taking the UCS-4 notation
defined by ISO/IEC 10646-1 and removing the leading two hexits, whose
values are always 0 (zero).
--/small
--/i
--/p
::=
--p
--i
--small
Syntax rule 22: is equivalent to a
single instance of .
--/small
--/i
--/p
::=
--p
--i
--small
Syntax rule 15: shall be a single character
from the source language character set other than a , , or .
--/small
--/i
--/p
--p
--i
--small
Syntax rule 16: If the source language character set contains , then let DEC be ; otherwise, let DEC be an
implementation-defined character from the source language character set
that is not a , , , or .
--/small
--/i
--/p
--p
--i
--small
Syntax rule 17: If a does not contain
, then "UESCAPE DEC" is
implicit.
--/small
--/i
--/p
--p
--i
--small
Syntax rule 18: In a there shall be no
between the and the first
, nor between any of the s.
--/small
--/i
--/p
::= !! See the Syntax Rules (15-18 above).
--p
--i
--small
Syntax rule 6: A is any character of
the source language character set other than a .
--/small
--/i
--/p
::= !! See the Syntax Rules.
--p
--i
--small
The rule for in the standard uses two adjacent
literal double quotes rather than referencing ; the
reasons are not clear.
It is annotated '!! two consecutive double quote characters'.
--/small
--/i
--/p
::= ::=
|
|