602SQL Documentation Index  

SQL Syntax Description in 602SQL

The modified BNF (Backus Naur Form) is used for SQL syntax notation. The syntax is described by a set of rules in the following form:

nonterminal ::= nonterminal_syntax_description

The right side specifies what syntax the nonterminal on the left side can have. It contains symbols that can be written directly in SQL (terminal symbols) and nonterminals defined by other rules. Metasymbols can also be used on the right side (metasymbols are symbols which are not part of the syntax, but allow syntax notation). Metasymbols are as follows:

| option separator, one of the options may be used
[ ] brackets that delimit the optional section
{ } metabraces (delimit a certain part of the rule)
a symbol designating zero or more recurrences of the immediately previous symbol (or more symbols in metabraces)

An example of notation use:

statement_INSERT ::= INSERT INTO table_name [ ( column_name {,column_name} ) ] contents
contents ::= VALUES ( value {, value } ) | DEFAULT VALUES | query_expression

How to Read this Notation:

The INSERT statement begins with the mandatory INSERT INTO reserved words followed by the table_name nonterminal. The table_name nonterminal meaning is clear in this case.

The brackets that delimit the optional section containing parenthesis are in this section. They are not metasymbols and are therefore part of the statement. The parenthesis contain one or more nonterminals, column_name. The braces here delimit the section for the repeat symbol.

The nonterminal contents follows. The syntax is defined in the following rule. Three different syntax options are specified by the option separators. The first option begins with the VALUES keyword and continues with a list of one or more values in parenthesis. The second section is composed only of the DEFAULT VALUES keyword. The third option refers to the query_expression nonterminal. Query_expression is a construct mentioned in many places, therefore it is defined on a special page.

An example of the INSERT statement that fulfills this rule is as follows:

INSERT INTO Inventory(name, id, price) VALUES ('Empo', 546000, 489.20)

Typographical Notes

We will use the following conventions in the examples: table names are written with the first letter capitalized, column names with lowercase letters, and SQL reserved keywords in all capital letters.