IBM Books

Quick Beginnings


Setting the Operating Environment for Each DB2 Instance User on UNIX Systems

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.

* Figure hint not displayed.

The sample scripts contain statements to:

  • Update a user's PATH by adding the following directories to the existing search path:
       INSTHOME/sqllib/bin
       INSTHOME/sqllib/adm
       INSTHOME/sqllib/misc
    

    where INSTHOME is the home directory of the instance.

  • Set the DB2INSTANCE environment variable to the instance name.

 

The sample scripts can be invoked in two ways:

Setting the DB2 Environment Automatically

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.

Setting the DB2 Environment Manually

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.

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.

* Figure hint not displayed.

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.  


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]

[ DB2 List of Books | Search the DB2 Books ]