DB2 Version 9.7 for Linux, UNIX, and Windows

Identifying the current instance

Most commands that you issue or configuration changes that you make apply by default to the current instance. You can identify the current instance by checking the values of certain environment variables.

About this task

When you run commands to start or stop the database manager for an instance, the database manager applies the command to the current instance. To determine the current instance, the database manager checks the values of certain environment variables in the following order:

  1. The value of the DB2INSTANCE environment variable for the current session.
  2. The value of the DB2INSTANCE system environment variable.
  3. On Windows operating systems, the value of the DB2INSTDEF registry variable.

Procedure

To identify the current instance:

Check the value of the relevant environment variable.
Option Description
View the value of the DB2INSTANCE environment variable for the current session. Issue the following command:
db2 get instance
View the value of the DB2INSTANCE system environment variable.
  • On Windows operating systems, issue the following command:
    echo %DB2INSTANCE%
  • On Linux and UNIX operating systems, issue the following command:
    echo $DB2INSTANCE
View the value of the DB2INSTDEF registry variable. Issue the following command:
db2set DB2INSTDEF