BNF Grammar for ISO/IEC 9075:1999 - Database Language SQL (SQL-99)
==================================================================
@(#)$Id: sql-99.bnf,v 2.8 2004/07/26 18:00:06 jleffler Exp $
--p
Using Appendix G of "SQL:1999 Understanding Relational Language Components" by J
Melton and A R Simon (Morgan Kaufmann, May 2001, ISBN 0-55860-456-1)
as the primary source of the syntax, here is the BNF syntax for SQL-99.
The Word 97 version of this document is available from:
--##
--## http://www.mkp.com/books_catalog/catalog.asp?ISBN=1-55860-456-1 .
--/p
--p
Note that this version of this file includes the corrections from ISO 9075:1999/Cor.1:2000.
--/p
--p
The plain text version of this grammar is
--## sql-99.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 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 Identifying the version of SQL in use
--/h2
--p
This material (starting with ) is defined in
section 6.3 "Object Identifier for Database Language SQL" of ISO/IEC
9075-1:1999 (SQL Framework).
It is used to express the capabilities of an implementation.
The package names are identifiers such as 'PKG001', equivalent to
'Enhanced datetime facilities', as defined in the informative Annex B to
SQL Framework.
Each such package identifies a number of features that are provided when
the SQL object identifier claims to provide the package.
--/p
::=
::=
::= iso | 1 | iso 1
::= standard | 0 | standard 0
::= 9075
::=
::= <1987> | <1989> | <1992> | <1999>
<1987> ::= 0 | edition1987 0
<1989> ::= <1989 base> <1989 package>
<1989 base> ::= 1 | edition1989 1
<1989 package> ::= |
::= 0 | IntegrityNo 0
::= 1 | IntegrityYes 1
<1992> ::= 2 | edition1992 2
<1999> ::= 3 | edition1999 3
::=
::= | |
::= 0 | Low 0
::= 1 | Intermediate 1
::= 2 | High 2
::=
--p
--small
--i
The parenthesized (i) and (n) are italic in the SQL standard.
It is not clear exactly what this should look like, despite all the
information.
However, it is also not important; this is not really a part of the SQL
language per se.
Note that the package numbers are PKG001 to PKG009, for example.
We still have to devise a mechanism to persuade bnf2yacc.pl to ignore
this information.
--/i
--/small
--/p
::= ...
::= |
::= 0 | Part-(n)No 0
::= !! (as specified in ISO/IEC 9075-(n))
::= |
::=
::= 3 | sqlcli1999 3
::=
::= 4 | sqlpsm1999 4
::= |
::= 1 | moduleyes 1
::= 0 | moduleno 0
::=
--p
--small
--i
The original used sqlbindings199x, but the x should clearly be a 9.
--/i
--/small
--/p
::= 5 | sqlbindings1999 5
::= |
::= 1 | directyes 1
::= 0 | directno 0
::= | ...
::= 0 | embeddedno 0
::=
|
|
|
|
|
|
::= 1 | embeddedAda 1
::= 2 | embeddedC 2
::= 3 | embeddedCOBOL 3
::= 4 | embeddedFortran 4
::= 5 | embeddedMUMPS 5
::= 6 | embeddedPascal 6
::= 7 | embeddedPLI 7
--hr
--h2 Basic Definitions of Characters Used, Tokens, Symbols, Etc.
--/h2
--p
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
::=
::= | |
::=
|
::=
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)
::= "
::= %
::= &
::= '
::= (
::= )
::= *
::= +
::= ,