Syntax rules for DB2 commands

Standard syntax rules apply to DB2® commands.

General conventions for syntax diagrams

For information about the conventions for syntax diagrams in IBM® documentation, see How to read syntax diagrams.

Conventions for DB2 commands syntax

For the complete syntax of specific commands, see the "Syntax" section for each command under DB2 and related commands.

The following figure illustrates the overall pattern of DB2 command syntax.

Figure 1. The format and parts of a DB2 command
Begin figure summary. This figure shows the various syntax elements of the DISPLAY DATABASE command. Detailed description available.
A DB2 command contains the following parts:
Recognition character
Shown as a hyphen throughout this information, with the following exceptions:
  • If the command is issued from a z/OS® console, the recognition character must be the command prefix.

    The command prefix can be up to eight characters. The default is '-DSN1'. However, the majority of examples in this information assume that the command prefix has been defined as a hyphen (-). Examples involving members of a data sharing group demonstrate the use of multi-character command prefixes, such as -DB1G.

    Inserting a space between the command prefix and the command is optional. For example, you can use either one of the following formats:
    -DB1GDIS THREAD(*)
    -DB1G DIS THREAD(*)
    Using a space makes it easier for users to identify the command, especially when the command prefix has multiple characters.

    The command prefix can be defined at installation time.

  • If the command is issued from an IMS™ terminal, the recognition character must be the command recognition character (CRC). The command recognition character is defined in the IMS SSM PROCLIB member.
  • If the command is issued from a CICS® terminal or under the DSN command processor, the recognition character must be a hyphen.
Command name
The name of the command. Command names have abbreviations, which are provided in the description of each command.
Operands
Combinations of keywords and parameters that can be specified for the command.
Keywords
Sometimes called command options. Keywords can be required or optional. They must be entered exactly as shown in the descriptions of the commands.
Parameters
A keyword can have zero or more parameters. A parameter list, if present, must be enclosed in parentheses.
Separators
These can be one or more blanks or commas. An open parenthesis marks the beginning of a parameter list; no separator is needed. Optionally, an equal sign can be used to separate a single parameter from its keyword without using parentheses.

Characters with special meanings in DB2 commands

The following characters have special meanings when they are used in DB2 commands:
Blank or blanks ( )
A separator. Single blanks and multiple blanks are equivalent, except in strings that are enclosed between apostrophes.
Comma (,)
A comma is a separator.
Apostrophe (')
The usual SQL string constant delimiter, and marks the beginning or end of a string constant in SQL. (In COBOL programs only, the QUOTESQL precompiler option allows you to choose the quotation mark as the SQL string delimiter; the apostrophe is then the SQL escape character.)

Letters that are not in string constants are changed to uppercase. Two successive apostrophes in a string constant are changed to one apostrophe. Blanks, commas, equal signs, and parentheses in string constants are treated as literal characters, and are not recognized as separators.

Use apostrophes to enclose options that must have lowercase characters. Beware of commands that do not convert lowercase characters to uppercase because entering lowercase letters might cause a JCL error or an abend. Similarly, entering uppercase letters where lowercase is required (UNIX Services, for example) might produce incorrect results. For more information, see Starting a system task from a console.

There is an exception to the rule about changing letters to uppercase. If the CODED CHARACTER SET option is set to 930 or 5026 during installation, the letters are not folded to uppercase, whether in an SQL string constant or not.

Start of changeIf a keyword value contains leading or following asterisk (*) or underscore (_) pattern-matching characters, and the characters in the keyword value are enclosed in apostrophes, the leading or following pattern-matching characters must also be enclosed in those apostrophes.End of change

Quotation mark (")
The SQL escape character, and marks the beginning or end of an SQL delimited identifier. (In COBOL programs only, the QUOTESQL precompiler option allows you to choose the apostrophe as the SQL escape character; the double quotation mark is then the SQL string delimiter.)

Within a string delimited by quotation marks, two successive quotation marks are changed to one. Other rules are the same as for SQL string constants.

Equal sign (=)
Separates a single parameter from a keyword. Thus, an equal sign is used as a separator for keywords that have only one parameter. An equal sign can be used for keywords with multiple parameters when only one member of the parameter list is specified.
open parenthesis (()
An open parenthesis marks the beginning of a parameter list.
Close parenthesis ())
The end of a parameter list.
Colon (:)
An inclusive range. For example, (A:D) means the same as (A,B,C,D); (1:5) means (1,2,3,4,5). The colon can be used this way only in commands where this operation is specifically permitted.
Asterisk (*)
The meaning depends on the context:
*
A single asterisk as a keyword-value indicates "all". For example:
-DISPLAY UTILITY (*)
*keyword-value
An asterisk as the first character of a keyword-value indicates that a match for the value will be satisfied when all characters following the * are the same. For example: (*BCD)
beginning-of-keyword-value*end-of-keyword-value
An intermediate asterisk indicates that a match for the value will be satisfied when all characters preceding and all characters following the asterisk are the same. For example: (ABC*EFG)
keyword-value*
An asterisk as the final character of a keyword-value indicates that a match will for the value will be satisfied when all characters preceding the asterisk are the same. For example: (ABC*)
beginning-of-keyword-value*middle-of-keyword-value*end-of-keyword-value*
Asterisks used as the first, intermediate and final characters in a string are also valid. For example: (*BCD*FGH*)
For example, DISPLAY UTILITY (*) displays the status of all utilities; DISPLAY UTILITY (R2*) displays the status of all utilities whose identifiers begin with R2.

The asterisk pattern-matching character is available to all DB2 commands, but not all DB2 commands support it. The asterisk can be used this way only in commands in which the pattern-matching operation is specifically supported.

Start of changeUnderscore (_)End of change
Start of changeAn underscore indicates that at the position in the keyword value where the underscore occurs, any character is a match for that value. For example, A_C matches any three-character keyword value with A as the first character and C as the third character.End of change
The two-character string NO
Negates the keyword that follows.

A negated keyword means the opposite of the keyword itself, and is often used to override a keyword default. In keywords that have no opposite meaning, the initial characters "NO" can be merely part of the keyword itself; for example, in NODE.