Working with instances on the same or different Db2 copies

You can run multiple instances concurrently, in the same Db2 copy or in different Db2 copies.

About this task

To prevent one instance from accessing the database of another instance, the database files for an instance are created under a directory that has the same name as the instance name. For example, when creating a database on drive C: for instance DB2, the database files are created inside a directory called C:\DB2. Similarly, when creating a database on drive C: for instance TEST, the database files are created inside a directory called C:\TEST. By default, its value is the drive letter where Db2 product is installed. For more information, see the dftdbpath database manager configuration parameter.

Procedure

  • To work with instances in the same Db2 copy, you must:
    1. Create or upgrade all instances to the same Db2 copy.
    2. Set the DB2INSTANCE environment variable to the name of the instance you are working with.
      This action must occur before you issue commands against the instance.
  • To work with an instance in a system with multiple Db2 copies, use either of the following methods:
    • Use the Command window from the Start > Programs > IBM Db2 Copy Name > Command Line Tools > Db2 Command Window. The Command window is already set up with the correct environment variables for the particular Db2 copy chosen.
    • Use db2envar.bat from a Command window:
      1. Open a Command window.
      2. Run the db2envar.bat file using the fully qualified path for the Db2 copy that you want the application to use:
        DB2_Copy_install_dir\bin\db2envar.bat