Commands in Db2

You can use commands for many tasks that you do to control and maintain Db2 subsystems.

Privileges and authorization IDs for commands

Commands can be issued by an individual users, by programs that run in batch mode, or by IMS or CICS® transactions. The term process describes any of these initiators. Db2 processes are represented by a set of identifiers (IDs), which are called authorization IDs. What the process can do with Db2 is determined by the privileges and authorities that are held by its identifiers.

If RACF® is active, IDs that issue commands from logged-on MVS™ consoles or from TSO SDSF must have appropriate RACF authorization for Db2 commands, or the primary authorization IDs must have Db2 authorization to issue commands.

Db2 commands that are issued from a logged-on z/OS® console or TSO SDSF can be checked by Db2 authorization using primary and secondary authorization IDs.

You can use Db2 authorization to check Db2 commands that are issued from a DSN session under TSO or DB2I by using primary authorization IDs, secondary authorization IDs, and role, if the commands are running in a trusted context with an associated role.

SQL IDs do not affect most Db2 and related commands.

For more information, see Authorization IDs and Privileges and authorities.

Command types in Db2

Db2 supports the following different types of commands:

  • The TSO command DSN and its subcommands
  • Db2 commands
  • CICS attachment facility commands
  • IMS commands
  • Administrative task scheduler commands
  • z/OS IRLM commands
  • TSO CLISTs

For more information, see Command types and environments in Db2.

Syntax rules for Db2 commands

For more information about the conventions for syntax diagrams in the Db2 product documentation, see How to read syntax diagrams.

The syntax of each 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. 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(*)
    However, using a space makes it easier for users to identify the command, especially when the command prefix has multiple characters.
  • 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.
The following table lists characters that have special meanings when they are used in Db2 commands.
Table 1. Special meanings of characters in Db2 commands
Character Meaning in commands
Blank or blanks ( ) A separator. Single blanks and multiple blanks are equivalent, except in strings that are enclosed between apostrophes.
Comma (,) A separator. Single blanks and multiple blanks are equivalent, except in strings that are enclosed between apostrophes.
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.

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

If 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.

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 (() 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; whereas, 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.

Underscore (_) Indicates that any character is a match a that position in a keyword value. For example, A_C matches any three-character keyword value with A as the first character and C as the third character.
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.

Syntax rules for DSN subcommands

The syntax rules for DSN subcommands conform to standard TSO command parsing conventions. For general information about the syntax of TSO/E commands and subcommands, see TSO/E commands and subcommands.

To continue a subcommand on the next line in the DSN processor, type either a hyphen (-) or a plus sign (+) at the end of the current line. If you use a plus sign, precede it by at least one blank character to prevent the concatenation of character strings from line to line. Using a plus sign causes TSO/E to delete leading delimiters (blanks, commas, tabs, and comments) on the continuation line, and reduces the overall size of the command.

Important: The names of the DSN command and its subcommands cannot be abbreviated. Abbreviations for some keywords are supported for compatibility with prior Db2 releases. However, avoid abbreviating keywords in the DSN command and its subcommand to avoid potential problems.

Data sharing scope of commands

In a data sharing environment, the scope of a command is the breadth of its impact among the members of the data sharing group. Many commands used in a data sharing environment have member (or local) scope because they affect only the Db2 subsystem for which they are issued. Other commands have group scope because they affect an object in such a way that affects all members of the group. For more information, see Command scope in Db2 data sharing or the Environment in the description of each command.

Output from commands

Several factors affect the amount of output you can receive from a Db2 command.

The amount of output that you receive from a Db2 command is always less than 256 KB. The following factors determine the maximum amount of output that is returned:
  • The amount of storage available to your Db2 subsystem or to an individual command.
  • The environment from which you issue the Db2 command.

    For example, if you issue a Db2 command from an IMS console, you can receive no more than 32 KB of output.

  • For DISPLAY DATABASE, the value of the LIMIT keyword. For more information, see -DISPLAY DATABASE command (Db2).
  • For DISPLAY THREAD, the number of lines of output. DISPLAY THREAD displays at most 254 lines of output. For more information, see -DISPLAY THREAD command (Db2).

Recovery logs and commands

All Db2 commands issued after Db2 restart and before Db2 shutdown are logged by Db2. These commands are written in an IFCID 90 trace record with a destination header that is mapped by macro DSNDQWIW. The log record type is 0010 (system event), and the subtype is 0041 (trace record).