How to set Oracle Environment Variable in Unix

Applies to: All unix based Operating system with Database Management Software Oracle.

1. First of all you need to know, exact location of Oracle Software installed. In a simple way this path starts from root to just above the "bin" directory like '/etc/oracle/oracle/bin'. So, Oracle s/w installation path will be '/etc/oracle/oracle'.

2. Go to user home directory:

[oracle@database oracle]$ cd ~
[oracle@database ~]$ pwd
/home/oracle
[oracle@database ~]$

In most of the cases it is '/home/oracle'. If you are using Oracle user for s/w installation.

3. edit .bash_profile file

[oracle@database ~]$ vi .bash_profile

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin
export PATH

4. Press 'i' to open this file in edit mode and paste following lines at the bottom of file. In your case value for ORACLE_HOME can be different.

export ORACLE_HOME=/etc/oracle/oracle
export PATH=$PATH:$ORACLE_HOME/bin

5. Press 'esc' button from your key board and then 'wq!' to shave changes.

6. Finally your .bash_profile will look like.

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin
export PATH
export ORACLE_HOME=/etc/oracle/oracle
export PATH=$PATH:$ORACLE_HOME/bin

7. To apply changes in this session use below. This is only one time activity.

[oracle@database ~]$ source .bash_profile

Now you are ready to use it.

[oracle@database ~]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.2.0 Production on Thu Jan 24 03:44:28 2013

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

SQL>

No comments:

Post a Comment