Before a user can use DB2, the database environment for each user must be updated so that it can access a DB2 instance and run the DB2 programs. This applies to all users (including administrative users).
Two sample scripts db2profile (for Bourne or Korn shell) and db2cshrc (for C shell) are provided to help you set the environment. These scripts are available in the INSTHOME/sqllib directory. The scripts are copied and customized when an instance is created.
The instance owner (or any user that belongs to the same primary group as
the instance owner) can customize the scripts for all users of an
instance. Alternatively, these scripts can be copied and customized for
each user.
The sample scripts can be invoked in two ways:
By default, the scripts affect the user environment for the duration of the current session only. You can change the .profile file to enable it to run the db2profile script automatically when the user logs on using the Bourne or Korn shell. For users of the C shell, you can change the .login file to enable it to run the db2cshrc script.
Add one of the following statements to the .profile or .login file.
. INSTHOME/sqllib/db2profile (in Bourne or Korn Shell) source INSTHOME/sqllib/db2cshrc (in C Shell)
where INSTHOME is the home directory of the instance that you want to use.
. $HOME/db2profile (in Bourne or Korn Shell) source $HOME/db2cshrc (in C Shell)
where $HOME is the home directory of user.
To choose which instance that you want to use, type one of the following statements at a command prompt. The period (.) and the space are required.
. INSTHOME/sqllib/db2profile (in Bourne or Korn Shell) source INSTHOME/sqllib/db2cshrc (in C Shell)
where INSTHOME is the home directory of the instance that you want to use.
. $HOME/db2profile (in Bourne or Korn Shell) source $HOME/db2cshrc (in C Shell)
If you want to work with more than DB2 instance at the same time, run the script for each instance, that you want to use in, separate windows. For example, assume that you have two DB2 instances called test and prod, and their home directories are /u/test and /u/prod. In window 1, you would type:
. /u/test/sqllib/db2profile (in Bourne or Korn Shell) source /u/test/sqllib/db2cshrc (in C Shell)
and in window 2, you would type:
. /u/prod/sqllib/db2profile (in Bourne or Korn Shell) source /u/prod/sqllib/db2cshrc (in C Shell)
You would use window 1 to work with the test instance and window
2 for the prod instance.
![]() |
To ensure that you are using the correct instance, use the following command: which db2 It will show you the full path name for the DB2 command. This path
should include the home directory of the instance.
|