There are times when we have more than 1 database on a single servers. So setting OS profile for oracle environment becomes complicated. Like how to set SID or oracle home for all Databases.

A Solution can be is creating a separate OS user for different database or can go with below statement. Editing oracle .profile in /home/oracle.

Below showing 5 different SID with 4 different versions of database, 10.1.0.1, 10.2.0.4, 11.1.0.7, 11.2.0.2. We can see there are two database DB4 and DB5 with same oracle version 11.2.0.2, so even in this case we need to have 2 different option 4 and 5 as the SID are different.

cat .profile
PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:.

export PATH

if [ -s "$MAIL" ]           # This is at Shell startup.  In normal
then echo "$MAILMSG"        # operation, the Shell checks
fi                          # periodically.

echo " "
echo " "
echo "            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "                                   Database options"
echo " "
echo " "
echo "                          1) DB1 DATABASE 10g"
echo " "
echo "                          2) DB2 DATABASE 10g"
echo " "
echo "                          3) DB3 DATABASE 11g"
echo " "
echo "                          4) DB4 DATABASE 11g"
echo " "
echo "                          5) DB5 DATABASE 11g"
echo "            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo " "
echo " "
echo "                    Enter Choice:\c"
read env
if [ $env -eq 1 ] ; then
    export ORACLE_HOME=/oracle/ora10101
    export ORACLE_BASE=/oracle
    export ORACLE_SID=DB1
    cd /database/DB1
    PS1='$PWD::10g-->'

else
    if [ $env -eq 2 ] ; then
    export ORACLE_HOME=/oracle/ora10204
    export ORACLE_BASE=/oracle
    export ORACLE_SID=DB2
    cd /database/DB2
    PS1='$PWD::10g-->'
    fi

    if [ $env -eq 3 ] ; then
    export ORACLE_HOME=/oracle/ora11107
    export ORACLE_BASE=/oracle
    export ORACLE_SID=DB3
    cd /database/DB3
    PS1='$PWD::11g-->'
    fi

    if [ $env -eq 4 ] ; then
    export ORACLE_HOME=/oracle/ora11202
    export ORACLE_BASE=/oracle
    export ORACLE_SID=DB4
    cd /database/DB4
    PS1='$PWD::11g-->'
    fi

    if [ $env -eq 5 ] ; then
    export ORACLE_HOME=/oracle/ora11202
    export ORACLE_BASE=/oracle
    export ORACLE_SID=DB5
    PS1='$PWD::11g-->'
    fi
fi

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib:/lib
export LIBPATH=$ORACLE_HOME/lib32:$ORACLE_HOME/lib:/usr/lib:/lib
export PATH=$PATH:$ORACLE_HOME/bin
stty erase ^?
TMOUT=0;TIMEOUT=600;export readonly TMOUT TIMEOUT
set -o vi

echo ''
echo ''
clear
echo
echo "ORACLE_SID=$ORACLE_SID"
echo

alias l='ls -lrt'
alias sqld='sqlplus "/as sysdba"'
Advertisements