Condensed SQL Language Syntax Definition

digit  ::=  0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
alpha ::= A..Z | a..z

special-character ::= A special-character is any character other
than a <digit> or an <alpha>.

delimiter ::= <alpha-literal> | , | ( | ) | < | > | . | : | = | * | +
| - | / | <> | >= | <= |

separator ::= <comment> | <space> | <newline>
comment ::= --[<character]*<newline>

lit-character ::= <nonquote> | ''
nonquote ::=
A nonquote is any character other than the single quote "'". Two consecutive quotes "''" may be used to represent an embedded quote "'".

integer ::= <digit>[<digit>]*

numeric-literal ::= [{+ | -}]<numeric-tail>
numeric-tail ::= <integer>[.[<integer>]] | .<integer>

approx-literal ::= <numeric-literal> E[{+ | -}] <integer>

alpha-literal ::= '[<lit-character>]*'

literal ::= <alpha-literal> | <numeric-literal> | <approx-literal>

identifier ::= <normal-identifier> | <delimited-identifier>
normal-identifier ::= <alpha>[<id-character>]*
delimited-identifier ::= "<any printable character string>"

id-character ::= <alpha> | <digit> | _

authorization-id ::= <short identifier>

location-id ::= <long identifier>

column-name ::= <long identifier>

table-name ::= <short identifier>

view-name ::= <long identifier>

statement-name ::= <short identifier>

range-variable ::= <long identifier>

table-ref ::= [<table-qualifier>.]<table-name>
table-qualifier ::= <loc-id>.<auth-id> | <auth-id>

column-ref ::= [<column-qualifier>.]<column-name>
column-qualifier ::= <table-ref> | <range-variable>

string-data-type ::= {CHARACTER | CHAR}[(<length>)]
length ::= <integer>

numeric-data-type ::= NUMERIC[<pr-sc>] | {DECIMAL | DEC} [<pr-sc>]
| INTEGER | INT | SMALLINT | FLOAT | REAL
| DOUBLE PRECISION
pr-sc ::= (<precision>[,<scale>])

date-data-type ::= DATE

scalar-exp ::= <term> | <scalar-exp> <addop> <term>

addop ::= + | -

term ::= <factor> | <term> <multop> <term>
multop ::= * | /
factor ::= <literal> | <column-ref> | <function-ref> | (<scalar-exp>)

comp-tail ::= <scalar-exp> | <subquery>

relop ::= = | <> | < | > | <= | >=

between-predicate ::= <scalar-exp> [NOT] BETWEEN <limits>
limits ::= <scalar-exp> AND <scalar-exp>

like-predicate ::= <column-ref> [NOT] LIKE <literal>

null-predicate ::= <column-ref> IS [NOT] NULL

in-predicate ::= <scalar-exp> [NOT] IN <value-set>
value-set ::= <subquery> | <enumeration>
enumeration ::= ( <scalar-exp> [,<scalar-exp>]* )

all-or-any-pred ::= <scalar-exp> <quant-op> <subquery>
quant-op ::= <relop> <quantifier>
quantifier ::= ALL | ANY | SOME

existence-predicate ::= EXISTS <subquery>

search-condition ::= <boolean-term> | <search-condition> OR
<boolean-term>
boolean-term ::= <boolean-factor> | <boolean-term> AND <boolean-factor>
boolean-factor ::= [NOT] <boolean-primary>
boolean-primary ::= <predicate> | ( <search-condition> )

function-ref ::= COUNT(*) | <distinct-fn-ref> | <all-fn-ref>
distinct-fn-ref ::= [<fn-name> | COUNT] ( DISTINCT <column-ref> )
all-fn-ref ::= <fn-name> ( [ALL] <scalar-exp> )
fn-name ::= AVG | MAX | MIN | SUM

query-exp ::= <query-exp-head> <order-by-clause>
query-exp-head ::= <query-term> | <query-exp> UNION [ALL] <query-term>
order-by-clause ::= ORDER BY <ord-spec> [, <ord-spec>]*
ord-spec ::= {<integer> | <column-ref>} [{ASC | DSC}]
query-term ::= <query-spec> | ( <query-exp> )
query-spec ::= SELECT [<sel-qualifier>] <selection> <table-exp>
sel-qualifier ::= ALL | DISTINCT
selection ::= <select-list> | *
select-list ::= <scalar-exp> [, <scalar-exp>]*

table-exp ::= <from-clause> [<where-clause>] [<group-by-clause>]
[<having-clause>]
from-clause ::= FROM <from-ref> [, <from-ref>]*
from-ref ::= <table-definition> [<range-variable>]
table-definition ::= { <table-ref> | <joined-table> | ( <joined-table>) }
joined-table ::= <table-definition><join-spec>
<table-definition><on-condition>
join-spec ::= { INNER JOIN | LEFT [OUTER] JOIN | RIGHT [OUTER] JOIN }
on-condition ::= ON <search-condition>
where-clause ::= WHERE <search-condition>
group-by-clause ::= GROUP BY <column-name> [, <column-name>]*

having-clause ::= HAVING <search-condition>

subquery ::= (SELECT [ALL | DISTINCT] <result-spec> <table-expression>)
result-spec ::= <scalar-exp> | *

prepare-statement ::= PREPARE <stmt-name> FROM <prototype>
prototype ::= <query-exp> | <delete-statement> |<insert-statement> |
<update-statement>

execute-statement ::= EXECUTE <stmt-name> [USING <parmlist>]
parmlist ::= <literal> [, <literal>]*

table-definition ::= CREATE TABLE <table-name>
(<column-definition> [,<column-definition>]*)
[<default-clause>] [<constraint>]

constraint ::= NOT NULL [UNIQUE]
default-clause ::= DEFAULT <default>
default ::= <literal> | NULL
column-definition ::= <column-name> <data-type>
data-type ::= <string-data-type> | <numeric-data-type>

view-definition ::= CREATE VIEW <view-name> [<column-list>] AS
<query-specification>
column-list ::= <column-name> [, <column-name>]

drop-statement ::= DROP {<table-name> | <view-name>}

insert-statement ::= <insert-row> | <insert-set>
insert-set ::= <insert-head> <query-spec>
insert-row ::= <insert-head> [<column-list>] VALUES <val-list>
insert-head ::= INSERT INTO <table-name>
val-list ::= <literal> [, <literal>]*

delete-statement ::= DELETE FROM <table-name> [<where-clause>]

update-statement ::= UPDATE <table-name> SET <asg-list> [<where-clause>]

asg-element ::= <column-name> = {<scalar-expression> | NULL }

asg-list ::= <asg-element>[, <asg-element>]*

commit-statement ::= COMMIT WORK

rollback-statement ::= ROLLBACK WORK

iWay Software