Ora from Oracle and env from environment makes 'oraenv' together. Simple, isn't it? So by the name it suggests from the beginning that it must have something to do with oracle environment.
Now what is oracle environment? Oracle environment is nothing but a collection of some oracle environment variables. These variables are $ORACLE_HOME, $LD_LIBRARY_PATH, $PATH and $ORACLE_SID.
Thanks
Now what is oracle environment? Oracle environment is nothing but a collection of some oracle environment variables. These variables are $ORACLE_HOME, $LD_LIBRARY_PATH, $PATH and $ORACLE_SID.
Now what is oraenv?
oraenv is a shell script provided by oracle for unix only. Remember only for unix, not for windows. It is used to set a user's environment to access an oracle database.
Now when is it created?
Do you remember the last step of a fresh oracle installation, where you are prompted to run 2 scripts as root, : root.sh and orainstRoot.sh. Yes, this root.sh copies oraenv to /usr/local/bin location so that it can be executed from any location.
How to execute oraenv?
We need to execute oraenv as . oraenv (dot space oraenv). Don't execute as only oraenv, cause if we use only oraenv, it will be not be executed in the current shell environment and so it won't be able to change the environment of the current shell, no matter how many times we put ORACLE_SID or ORACLE_HOME. Once we execute this, it asks for ORACLE_SID first and if we don't put the SID and hit enter it asks for ORACLE_HOME. These two are sufficient to set the rest of the 2. If we put any of this these 2, the rest of the 2 will automatically be set. That's why oraenv doesn't ask for all 4.
Once the environment is set you can all any of the binary files of oracle from any location.
I am including the oraenv script here. Have a look.
case ${ORACLE_TRACE:-""} in
T) set -x ;;
esac
#
# Determine how to suppress newline with echo command.
#
N=
C=
if echo "\c" | grep c >/dev/null 2>&1; then
N='-n'
else
C='\c'
fi
#
# Set minimum environment variables
#
# ensure that OLDHOME is non-null
if [ ${ORACLE_HOME:-0} = 0 ]; then
OLDHOME=$PATH
else
OLDHOME=$ORACLE_HOME
fi
case ${ORAENV_ASK:-""} in #ORAENV_ASK suppresses prompt when set
NO) NEWSID="$ORACLE_SID" ;;
*) case "$ORACLE_SID" in
"") ORASID=$LOGNAME ;;
*) ORASID=$ORACLE_SID ;;
esac
echo $N "ORACLE_SID = [$ORASID] ? $C"
read NEWSID
case "$NEWSID" in
"") ORACLE_SID="$ORASID" ;;
*) ORACLE_SID="$NEWSID" ;;
esac ;;
esac
export ORACLE_SID
ORAHOME=`dbhome "$ORACLE_SID"`
case $? in
0) ORACLE_HOME=$ORAHOME ;;
*) echo $N "ORACLE_HOME = [$ORAHOME] ? $C"
read NEWHOME
case "$NEWHOME" in
"") ORACLE_HOME=$ORAHOME ;;
*) ORACLE_HOME=$NEWHOME ;;
esac ;;
esac
export ORACLE_HOME
#
# Reset LD_LIBRARY_PATH
#
case "$LD_LIBRARY_PATH" in
*$OLDHOME/lib*) LD_LIBRARY_PATH=`echo $LD_LIBRARY_PATH | \
sed "s;$OLDHOME/lib;$ORACLE_HOME/lib;g"` ;;
*$ORACLE_HOME/lib*) ;;
"") LD_LIBRARY_PATH=$ORACLE_HOME/lib ;;
*) LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH ;;
esac
export LD_LIBRARY_PATH
#
# Put new ORACLE_HOME in path and remove old one
#
case "$OLDHOME" in
"") OLDHOME=$PATH ;; #This makes it so that null OLDHOME can't match
esac #anything in next case statement
case "$PATH" in
*$OLDHOME/bin*) PATH=`echo $PATH | \
sed "s;$OLDHOME/bin;$ORACLE_HOME/bin;g"` ;;
*$ORACLE_HOME/bin*) ;;
*:) PATH=${PATH}$ORACLE_HOME/bin: ;;
"") PATH=$ORACLE_HOME/bin ;;
*) PATH=$PATH:$ORACLE_HOME/bin ;;
esac
export PATH
#
# Install any "custom" code here
#
# Locate "osh" and exec it if found
ULIMIT=`LANG=C ulimit 2>/dev/null`
if [ $? = 0 -a "$ULIMIT" != "unlimited" ] ; then
if [ "$ULIMIT" -lt 2113674 ] ; then
if [ -f $ORACLE_HOME/bin/osh ] ; then
exec $ORACLE_HOME/bin/osh
else
for D in `echo $PATH | tr : " "`
do
if [ -f $D/osh ] ; then
exec $D/osh
fi
done
fi
fi
fi
T) set -x ;;
esac
#
# Determine how to suppress newline with echo command.
#
N=
C=
if echo "\c" | grep c >/dev/null 2>&1; then
N='-n'
else
C='\c'
fi
#
# Set minimum environment variables
#
# ensure that OLDHOME is non-null
if [ ${ORACLE_HOME:-0} = 0 ]; then
OLDHOME=$PATH
else
OLDHOME=$ORACLE_HOME
fi
case ${ORAENV_ASK:-""} in #ORAENV_ASK suppresses prompt when set
NO) NEWSID="$ORACLE_SID" ;;
*) case "$ORACLE_SID" in
"") ORASID=$LOGNAME ;;
*) ORASID=$ORACLE_SID ;;
esac
echo $N "ORACLE_SID = [$ORASID] ? $C"
read NEWSID
case "$NEWSID" in
"") ORACLE_SID="$ORASID" ;;
*) ORACLE_SID="$NEWSID" ;;
esac ;;
esac
export ORACLE_SID
ORAHOME=`dbhome "$ORACLE_SID"`
case $? in
0) ORACLE_HOME=$ORAHOME ;;
*) echo $N "ORACLE_HOME = [$ORAHOME] ? $C"
read NEWHOME
case "$NEWHOME" in
"") ORACLE_HOME=$ORAHOME ;;
*) ORACLE_HOME=$NEWHOME ;;
esac ;;
esac
export ORACLE_HOME
#
# Reset LD_LIBRARY_PATH
#
case "$LD_LIBRARY_PATH" in
*$OLDHOME/lib*) LD_LIBRARY_PATH=`echo $LD_LIBRARY_PATH | \
sed "s;$OLDHOME/lib;$ORACLE_HOME/lib;g"` ;;
*$ORACLE_HOME/lib*) ;;
"") LD_LIBRARY_PATH=$ORACLE_HOME/lib ;;
*) LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH ;;
esac
export LD_LIBRARY_PATH
#
# Put new ORACLE_HOME in path and remove old one
#
case "$OLDHOME" in
"") OLDHOME=$PATH ;; #This makes it so that null OLDHOME can't match
esac #anything in next case statement
case "$PATH" in
*$OLDHOME/bin*) PATH=`echo $PATH | \
sed "s;$OLDHOME/bin;$ORACLE_HOME/bin;g"` ;;
*$ORACLE_HOME/bin*) ;;
*:) PATH=${PATH}$ORACLE_HOME/bin: ;;
"") PATH=$ORACLE_HOME/bin ;;
*) PATH=$PATH:$ORACLE_HOME/bin ;;
esac
export PATH
#
# Install any "custom" code here
#
# Locate "osh" and exec it if found
ULIMIT=`LANG=C ulimit 2>/dev/null`
if [ $? = 0 -a "$ULIMIT" != "unlimited" ] ; then
if [ "$ULIMIT" -lt 2113674 ] ; then
if [ -f $ORACLE_HOME/bin/osh ] ; then
exec $ORACLE_HOME/bin/osh
else
for D in `echo $PATH | tr : " "`
do
if [ -f $D/osh ] ; then
exec $D/osh
fi
done
fi
fi
fi
That's all for now. Do not hesitate to correct or include any points or information that I have mentioned wrongly or missed completely. Your feedback is highly appreciated.
Thanks
Subhajit
No comments:
Post a Comment