Installation and Configuration Supplement

Entering Commands Using the Command Line Processor

You can use the command line processor to enter DB2 commands, SQL statements, and operating system commands. It operates in the following modes:

DB2 Command Window
The DB2 command line processor behaves like a command window from your operating system. You can enter operating system commands, DB2 commands, or SQL statements and view their output.

Interactive Input Mode
The db2 prefix that you use for DB2 commands (in the DB2 Command Window) is pre-entered for you. You can enter operating systems commands, DB2 commands, or SQL statements and view their output.

File Input Mode
Processes commands that are stored in a file. For information on the file input mode, refer to the Command Reference.

DB2 Command Window

To invoke a DB2 Command Window, do the following:

OS/2
Open any OS/2 command window.

Windows 32-bit operating systems
Click on Start and select Programs --> IBM DB2 --> Command Window

You can also invoke the DB2 command window by entering the db2cmd command at your operating system's prompt.

UNIX
Open any operating system command window.

If you are entering commands via the Command Window, you must include the db2 prefix. For example:

   db2 list database directory


Figure 00002674 not displayed.

If the DB2 command contains characters that have special meaning on the operating system you are using, you will need to enter the command in quotation marks to ensure that it is run properly.

For example, the following command would retrieve all the information from the employee table, even if the * character has a special meaning on the operating system:

   db2 "select * from employee"

To enter a long command that does not fit on a single line, you must use a space followed by the line continuation character "\" at the end of one line, then press the Enter key to continue the command on to the next. For example:

   db2 select empno, function, firstname, lastname, birthdate, from \
   db2 (cont.) => employee where function='service' and \
   db2 (cont.) => firstname='Lily' order by empno desc

Interactive Input Mode

To invoke the command line processor in interactive input mode, do the following:

OS/2
Click on OS/2 Warp and select IBM DB2 --> Command Line Processor or enter the db2 command.

Windows 32-bit operating systems
Click on Start and select Programs --> IBM DB2 --> Command Line Processor.

You can also invoke the command line processor in interactive input mode by entering the db2cmd command followed by the db2 command at your operating system's prompt.

UNIX
Enter the db2 command from the command line processor

In interactive input mode, the prompt looks like this:

   db2 =>

In interactive input mode, you do not have to enter DB2 commands with a db2 prefix; instead, you just enter the DB2 command. For example:

   db2 => list database directory

To enter operating-system commands in interactive mode, precede the operating system command with an exclamation mark (!). For example:

   db2 => !dir

To enter a long command that does not fit on a single line, you must use a space followed by the line continuation character "\" at the end of one line, then press the Enter key to continue the command on to the next. For example:

   db2 select empno, function, firstname, lastname, birthdate, from \
   db2 (cont.) => employee where function='service' and \
   db2 (cont.) => firstname='Lily' order by empno desc

To end interactive input mode, enter the quit command.

For more information on advanced topics using the CLP, refer to the Command Reference.


[ Top of Page | Previous Page | Next Page ]