You can use the command line processor to enter SQL statements and DB2 commands. It operates in the following modes:
To invoke the command line processor in interactive input mode, do the following:
You can also invoke the command line processor in interactive input mode, by entering the following command at a command prompt:
In interactive input mode, the prompt looks like this:
db2 =>
This prompt indicates that you do not type DB2 commands with a db2 prefix; instead, you just enter the DB2 command. For example:
list node directory
To run operating system commands in interactive mode, precede the operating-system command with an exclamation mark (!). For example:
!dir db2*.log
|
Windows 3.x does not support this method of running operating system
commands.
|
If you need to enter a long command that does not fit on one line, use the line continuation character, \. For example:
db2 => select firstname, lastname, dateofbirth, from \ staff where height=68, order by \ lastname
Note: | You do not need to use a line continuation character when entering long commands in interactive input mode on Windows 3.x workstations. |
To end interactive input mode, type terminate.
On UNIX, you can issue DB2 commands from a command prompt. You must include the db2 prefix. For example:
db2 list node directory
To invoke the command line processor in command line mode on Windows 95 and Windows NT operating systems, use one of the following methods:
After you invoke the DB2 command environment, you can enter DB2 commands at the command prompt. You must include the db2 prefix.
Notes:
db2 "select * from employee"
| For further information on using the command line processor, refer to the Command Reference. |
The default logical node is one that has a value of 0 for the logical_port parameter in the db2nodes.cfg file. By default, a client connects to the default logical node unless the DB2NODE environment variable is set to another node number. For all commands and applications that connect to a database, you must ensure that the DB2NODE environment variable is set to reference the node number of the logical node that you want the operation to run on. The node number of the logical node is in the db2nodes.cfg file. If the database partition server being connected to is not started on the machine, the application returns an error. In DB2 Extended Enterprise Edition, the set client command can also be used to target a specific node within a partitioned database system. For more information, refer to the Command Reference.
Remote applications always connect to the default node, unless the DB2NODE environment variable is set to another node number. Because all logical nodes on an instance share the same database manager configuration file, only one logical node per instance on a machine can service remote applications. The default node starts up the communication subsystem, if it was configured to do so. If the default node is shut down, the communication subsystem also ends. You will have to stop and restart a logical node on the machine to re-establish the communication subsystem. If you move the default node to another machine, on which logical nodes for that instance are already running, and one of the logical nodes already has a communication subsystem for remote clients, the restarted node cannot have one.
As an example, assume that you want to update the configuration of a database partition server that belongs to a database called TEST, and that database partition server is on a machine called MACH1. Also assume that you defined nodes 0 and 1 on MACH1. Because database configuration is defined at the database partition level, you would connect to each logical node on the machine and change the database configuration. You could do the following in two sessions on MACH1:
db2 connect to test
db2 connect reset db2 terminate
db2 connect to test
db2 connect reset db2 terminate
If you want, you can run session 1 and 2, one after the other.
When you are connected to a database, you can list the local database directory by issuing the list database directory on path command. The output will show the catalog node number for the database and the current node number where you are connected.