This is a small batch file changing the environmental settings based on the given instance name.

>>--- dbtuswitch.bat ---+----------------+---+------------+---><
                        |                |   |            |
                        +--- INSTANCE ---+   +--- NODE ---+
                        |                |
                        +--- default ----+
                        |                |
                        +--- current ----+

Syntax diagram

Running multiple DB2 instances / nodes on a single machine, you will frequently switch between them. This is where this script comes into the game.

Calling the script without any argument will get you a list of all available instances (except for the DB2 admin server instance). This list also contains information read from the configuration file [more].

Status    Name     Comment
--------- -------- --------------------------------------------------
-         DB2INST1
-         DB2

Sample output

Please notice, that the "Status" field as well as the "Comment" field is not supported on the Windows platform.

Running the script with the keyword "default" changes the environment to the default instance - defined in the configuration file [more]. The keyword "current" indicates to stay by the current instance, in combination with a node number (NODE). This is useful to switch the DB2 node only. It is also possible to repair / refresh the environment.

Switching the DB2 instance to a given name (INSTANCE) or keyword, the following steps are performed by the batch file: