Starting with Version 9.1, the DB2INSTANCE environment
is set according to the DB2® copy
that your environment is currently set up to use. If you do not set
it explicitly to an instance in the current copy, it defaults to the
default instance that is specified with the DB2INSTDEF profile registry
variable.
About this task
DB2INSTDEF is the default instance variable that is specific
to the current DB2 copy in use.
Every DB2 copy has its own DB2INSTDEF
profile registry variable. Instance names must be unique on the system;
when an instance is created, the database manager scans through existing
copies to ensure its uniqueness.
Use the following guidelines to
set the default instance when using multiple DB2 copies:
- If DB2INSTANCE is not set for a particular DB2 copy, then the value of DB2INSTDEF is used
for that DB2 copy. This means:
- If DB2INSTANCE=ABC and DB2INSTDEF=XYZ, ABC is the value that is
used
- If DB2INSTANCE is not set and DB2INSTDEF=XYZ, XYZ is used
- If DB2INSTANCE is not set and DB2INSTDEF is not set,
then any application or command that depends on a valid DB2INSTANCE
will not work.
- You can use either the db2envar.bat command
or the db2SelectDB2Copy API to switch DB2 copies.
Setting all the environment variables appropriately (for example,
PATH,INCLUDE,LIB and DB2INSTANCE) will also work, but you must ensure
that they are set properly.
Note: Using the
db2envar.bat command
is not quite the same as setting the environment variables. The db2envar.bat
command determines which DB2 copy
it belongs to, and then adds the path of this DB2 copy to the front of the PATH environment
variable.
When there are multiple DB2 copies
on the same computer, the PATH environment variable can only point
to one of them: the DEFAULT COPY. For example, if DB2COPY1 is under
c:\sqllib\bin and is the default copy; and DB2COPY2 is under d:\sqllib\bin.
If you want to use DB2COPY2 in a regular command window, you would
run d:\sqllib\bin\db2envar.bat in that command window. This adjusts
the PATH (and some other environment variables) for this command window
so that it will pick up binaries from d:\sqllib\bin.
- DB2INSTANCE is only valid for instances under the DB2 copy that you are using. However, if you
switch copies by running the db2envar.bat command,
DB2INSTANCE will be updated to the value of DB2INSTDEF for the DB2 copy that you switched to initially.
- DB2INSTANCE is the current DB2 instance
that will be used by applications that are executing in that DB2 copy. When you switch between
copies, by default, DB2INSTANCE is changed to the value of DB2INSTDEF
for that copy. DB2INSTDEF is less meaningful on a one copy system
because all the instances are in the current copy; however, it is
still applicable as being the default instance, if another instance
is not set.
- All global profile registry variables are specific to a DB2 copy, unless you specify them
using SET VARIABLE=<variable_name>.