DB2 10.5 for Linux, UNIX, and Windows

db2 - Command line processor invocation command

The db2 command starts the command line processor (CLP). The CLP is used to execute database utilities, SQL statements and online help.

It offers a variety of command options, and can be started in:
  • Interactive input mode, characterized by the db2 => input prompt
  • Command mode, where each command must be prefixed by db2
  • Batch mode, which uses the -f file input option.

On Windows operating systems, db2cmd command opens the CLP-enabled DB2® window, and initializes the DB2 command line environment. Issuing this command is equivalent to clicking on the DB2 Command Window icon.

The QUIT command stops the command line processor. The TERMINATE command also stops the command line processor but also removes the associated backend process and frees any memory that is being used. You should issue the TERMINATE command before issuing every STOP DATABASE MANAGER or db2stop command. You might also need to issue the TERMINATE command after changing the values of database configuration parameters, so that these changes take effect. You should reset connections before terminating the CLP.

The shell command, (!), allows operating system commands to be executed from the interactive or the batch mode on Linux and UNIX operating systems, and on Windows operating systems (!ls on UNIX, and !dir on Windows operating systems, for example).

Command Syntax

Read syntax diagramSkip visual syntax diagram
        | .-----------------.                        |   
        | V                 |                        |   
        |   '-option-flag-'    +-db2-command-------+ |   
        |                      +-sql-statement-----+ |   
        |                      '-?--+------------+-' |   
        |                           +-phrase-----+   |   
        |                           +-message----+   |   
        |                           +-sqlstate---+   |   
        |                           '-class-code-'   |   
        '- ----comment-------------------------------'   

Specifies a CLP option flag.
Specifies a DB2 command.
Specifies an SQL statement.
Requests CLP general help.
? phrase
Requests the help text associated with a specified command or topic. If the database manager cannot find the requested information, it displays the general help screen.

? options requests a description and the current settings of the CLP options. ? help requests information about reading the online help syntax diagrams.

? message
Requests help for a message specified by a valid SQLCODE (? sql10007n, for example).
? sqlstate
Requests help for a message specified by a valid SQLSTATE.
? class-code
Requests help for a message specified by a valid class-code.
-- comment
Input that begins with the comment characters -- is treated as a comment by the command line processor.

In each case, a blank space must separate the question mark (?) from the variable name.