Setting Oracle Environment Value on Different OS

ORACLE_BASE as a baseline directory off of which we fan out while ORACLE_HOME is the final destination for a particular ORACLE release version.

As your server lives and goes through multiple upgrades you’ll have the same ORACLE_BASE but multiple ORACLE_HOME’s underneath it.

Here’s a typical (OFA) structure of an ORACLE 10g install:

ORACLE_BASE = /u01/app/oracle/ ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1

Whenever install different Oracle Software in our machine. It is important to set the correct PATH and ORACLE_HOME environment variables in order to connect them always.

Windows Environment: Oracle 9i
Go to the computer=>properties=>Advanced=>Environment variable=>path and delete this then set the new path
Note: After setting the environment variables as above, open a fresh CMD tool and check whether they set properly or not. Do not try on already opened CMD tool to make sure the variables set or not.
Windows Environment: Oracle 10g

C:> set ORACLE_HOME=C:oracleappproduct10.2.0
C:> echo %ORACLE_HOME%
Linux Environment: Oracle 9i
We have to remove the ‘PATH’ variable from .bash_profile or we can set separate .bash_profile for each Oracle Database versions and we can use export in place of set command.
export PATH=${PATH}:${ORACLE_HOME}/bin

or check where in your environment Oracle home is. If ORACLE_HOME is not set, you can set it in your ${HOME}/.profile or {HOME}/.bash_profile, you can set any variable in those files and they will be available in your environment. Don’t forget, after adding the variables to reload your profile, with logout/login or “. ${HOME}/.profile” or “. ${HOME}/.bash_profile”

Linux Environment: Oracle 10g

Define the ORACLE_HOME value in the user profile file i.e. .bash_profile or .profile
ORACLE_HOME=$ORACLE_BASE/product/10.2.0
export ORACLE_HOME
Source the user profile as follows:
Bash shell:
$ . ./.bash_profile
Bourne shell or Korn shell:
$ . ./.profile
C shell:
% source ./.login
If no profile file is set with environment variables, then physically also be set as follows:
Bourne, Bash, or Korn shell:
$ ORACLE_BASE=/oracle/app
$ export ORACLE_BASE
$ ORACLE_HOME=$ORACLE_BASE/product/10.2.0
$ export ORACLE_HOME
C Shell:
% setenv ORACLE_BASE /oracle/app
% setenv ORACLE_HOME /oracle/app/product/10.2.0
——————————————————————————————————————–

How to check if ORACLE_HOME is set already?

Windows Environment:

Through SQL Query in 9i:

SQL>SELECT substr(file_spec,1,instr(file_spec,’lib’)-2) ORACLE_HOME

FROM dba_libraries WHERE library_name=’DBMS_SUMADV_LIB’;

Oracle 10g:
SQL>var OHM varchar2(100);
SQL>EXEC dbms_system.get_env(‘ORACLE_HOME’, :OHM) ;
SQL>PRINT OHM

Through Registry

start – run – regedit (enter) – HKEY_LOCAL_MACHINE – SOFTWARE – ORACLE
Through Command Prompt:
Type the below command at prompt and press Enter if the environment variable is defined for ORACLE_HOME will display:
c:>set ORACLE_HOME

To check specific environment variable set:
or
C:>echo %ORACLE_HOME%
To check all the environment variables set:
C:>setLinux/Unix Environment:

To check specific environment variable set:
$ echo $ORACLE_HOME
To check all the environment variables set:
$ env

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s