Before users can use DB2, the database environment for each user must be updated so that it can access an instance and run the DB2 programs. This applies to all users (including administrative users).
The sample scripts, db2profile (for Bourne or Korn shell) and db2cshrc (for C shell), are provided to help you set the database environment. These scripts are available in the INSTHOME/sqllib directory, where INSTHOME is the home directory of the instance owner.
These scripts are also required when the db2start and the db2stop commands are run to start or stop the DB2 Extended Enterprise Edition database manager.
The instance owner (or any user that belongs to the instance's SYSADM
group) can customize the script for all users of an instance.
Alternatively, the script can be copied and customized for each user.
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 file.
Add one of the following statements to the .profile or .login script files.
. INSTHOME/sqllib/db2profile (for Bourne or Korn shell) source INSTHOME/sqllib/db2cshrc (for C shell)where INSTHOME is the home directory of the instance that you want to use.
. USERHOME/db2profile (in Bourne or Korn Shell) source USERHOME/db2cshrc (in C Shell)
To choose which instance that you want to use, enter one of the following statements at a command prompt. The period (.) and the space are required.
. INSTHOME/sqllib/db2profile (for Bourne or Korn shell) source INSTHOME/sqllib/db2cshrc (for C shell)where INSTHOME is the home directory of the instance that you want to use.
. USERHOME/db2profile (in Bourne or Korn Shell) source USERHOME/db2cshrc (in C Shell)
If you want to work with more than one 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 instances called test and prod, and their home directories are /u/test and /u/prod.
In window 1:
. /u/test/sqllib/db2profile
source /u/test/sqllib/db2cshrc
In window 2:
. /u/prod/sqllib/db2profile
source /u/prod/sqllib/db2cshrc
Use window 1 to work with the test instance and window 2 to work
with the prod instance.
|
Issue the which db2 command to ensure that your search path has
been set up correctly. This command returns the absolute path of the
DB2 CLP executable. Verify that it is located under the instance's
sqllib directory.
|