DB2 Version 9.7 for Linux, UNIX, and Windows

How to read the syntax diagrams

SQL syntax is described using the structure defined as follows:

Read the syntax diagrams from left to right and top to bottom, following the path of the line.

Right chevrons and a hyphen >>- indicate the beginning of a syntax diagram.

Hyphens and a right chevron --> indicate that the syntax is continued on the next line.

A right chevron and hyphens >-- indicate that the syntax is continued from the previous line.

Hyphens followed by a right chevron and a left chevron -->< indicate the end of a syntax diagram.

Syntax fragments start with a vertical bar and hyphens|-- and end with hyphens and a vertical bar--| .

Required items appear on the horizontal line (the main path).

Read syntax diagramSkip visual syntax diagram
>>-required_item-----------------------------------------------><

Optional items appear below the main path.

Read syntax diagramSkip visual syntax diagram
>>-required_item--+---------------+----------------------------><
                  '-optional_item-'   

If an optional item appears above the main path, that item has no effect on execution, and is used only for readability.

Read syntax diagramSkip visual syntax diagram
                  .-optional_item-.   
>>-required_item--+---------------+----------------------------><

If you can choose from two or more items, they appear in a stack.

If you must choose one of the items, one item of the stack appears on the main path.

Read syntax diagramSkip visual syntax diagram
>>-required_item--+-required_choice1-+-------------------------><
                  '-required_choice2-'   

If choosing one of the items is optional, the entire stack appears below the main path.

Read syntax diagramSkip visual syntax diagram
>>-required_item--+------------------+-------------------------><
                  +-optional_choice1-+   
                  '-optional_choice2-'   

If one of the items is the default, it will appear above the main path, and the remaining choices will be shown below.

Read syntax diagramSkip visual syntax diagram
                  .-default_choice--.   
>>-required_item--+-----------------+--------------------------><
                  +-optional_choice-+   
                  '-optional_choice-'   

An arrow returning to the left, above the main line, indicates an item that can be repeated. In this case, repeated items must be separated by one or more blanks.

Read syntax diagramSkip visual syntax diagram
                  .-----------------.   
                  V                 |   
>>-required_item----repeatable_item-+--------------------------><

If the repeat arrow contains a comma, you must separate repeated items with a comma.

Read syntax diagramSkip visual syntax diagram
                  .-,---------------.   
                  V                 |   
>>-required_item----repeatable_item-+--------------------------><

A repeat arrow above a stack indicates that you can make more than one choice from the stacked items or repeat a single choice.

Keywords appear in uppercase (for example, FROM). They must be spelled exactly as shown. Variables appear in lowercase (for example, column-name). They represent user-supplied names or values in the syntax.

If punctuation marks, parentheses, arithmetic operators, or other such symbols are shown, you must enter them as part of the syntax.

Sometimes a single variable represents a larger fragment of the syntax. For example, in the following diagram, the variable parameter-block represents the whole syntax fragment that is labeled parameter-block:

Read syntax diagramSkip visual syntax diagram
>>-required_item--| parameter-block |--------------------------><

parameter-block

|--+-parameter1-----------------+-------------------------------|
   '-parameter2--+-parameter3-+-'   
                 '-parameter4-'     

Adjacent segments occurring between "large bullets" (●) may be specified in any sequence.

Read syntax diagramSkip visual syntax diagram
>>-required_item--item1--●--item2--●--item3--●--item4----------><

The above diagram shows that item2 and item3 may be specified in either order. Both of the following are valid:
   required_item item1 item2 item3 item4
   required_item item1 item3 item2 item4