Skip to content

What is oraenv in the unix environment- useful reference for the new oracle dba




you are a new oracle dba and you logged into the unix server as your oracle database is present in that server. after you login as the oracle user into the server you would like to start a sqlplus session for example sqlplus / as sysdba  and once you execute the command you get a message saying

SQL*Plus: Release 10.2.0.4.0 – Production on Wed Feb 23 09:27:43 2011

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.

Connected to an idle instance.

SQL>

the message idle instance means your database is not started. however this doesnt necessarily mean that your database has not started. It means that you have to first verify if your oracle environment is correctly configured. for example i normally verify if my environment is correctly configured by looking at my command prompt and my command prompt is as below

kadut03*testinst-/home/ora10 :->

my database name is sriinst ..however i see in the command prompt that my default instance was present as testinst and this is not my database.

so i now want to set my correct database instance . to do this i use the oraenv tool as below

kadut03*testinst-/home/ora10 :->. oraenv
ORACLE_SID = [testinst] ? sriinst
kadut03*sriinst-/home/ora10 :->

so if you look at above example the oraenv tool had asked me to enter my oracle instance name and i entered and it immediately set the instance name and now i can start my sqlplus session and log in successfully into my database.

Below article explains in detail about the ORAENV tool .

oraenv

The oraenv and coraenv utilities both aid in setting the Oracle environment on  UNIX  systems (other utilities exist on Windows platform that enable the Oracle Home to be set.) The coraenv utility is appropriate for the  UNIX  C Shell; oraenv should be used with either the Bourne or Korn shells.

Database operations require the ORACLE_HOME to be set before the user may access the database.  If ORACLE_HOME is not set, commands such as sqlplus, exp, or any other utility for that matter, will not be found.

Both utilities are shell scripts that do the same thing in the different  UNIX  shells.  They will prompt for a SID of the database unless ORAENV_ASK is set to N.  The utility will also append the ORACLE_HOME value to the path, marking the location of the utility.

The oraenv command will prompt for the SID of the database that you wish $ORACLE_HOME to access.

$ . oraenv

ORACLE_SID = [] ? ASG920

The dbhome utility can now be used to verify that $ORACLE_HOME is correct.  

$ dbhome

/usr/oracle/9.2.0

The “dot space” part of the command is required to make the environment change with the parent shell, as opposed to entering a command without it which would only affect the subshell running that process.

These commands can be used to avoid specifying the network service name when issuing commands.  For instance, without using oraenv, a sqlplus command would look like:

$ sqlplus system/manager@nameofservice as sysdba

whereas after oraenv has been executed, the following command would work:

$ sqlplus system/manager as sysdba

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Post a Comment

You must be logged in to post a comment.