Database Reference
In-Depth Information
Establishing OS Variables
Before connecting to your database via SQL*Plus, RMAN, Data Pump (or any other Oracle utility), you must first set
several OS variables:
ORACLE_HOME
•
ORACLE_SID
•
LD_LIBRARY_PATH
•
PATH
The
ORACLE_HOME
variable is important because it defines the starting point directory for locating the Oracle
binary files (such as
sqlplus
,
dbca
,
netca
,
rman
, and so on) that are located in
ORACLE_HOME/bin
.
The
ORACLE_SID
(site identifier) variable defines the default name of the database you'll connect to.
ORACLE_SID
is also used to establish the default name for the parameter file, which is
init<ORACLE_SID>.ora
or
spfile<ORACLE_
SID>.ora
. By default, Oracle will look in
ORACLE_HOME/dbs
for these initialization files on Linux/Unix systems and
ORACLE_HOME\database
on Windows systems. The initialization file contains parameters that govern aspects of your
database, such as how much memory to allocate to your database, the maximum number of connections, and so on.
The
LD_LIBRARY_PATH
variable is important because it specifies where to search for libraries on Linux/Unix
boxes. The value of this variable is typically set to include
ORACLE_HOME/lib
.
The
PATH
variable specifies which directories are looked in by default when you type a command from the OS
prompt. In almost all situations,
ORACLE_HOME/bin
(the location of the Oracle binaries) must be included in your
PATH
variable.
You can either manually set these variables or use a standard script provided by Oracle to set these variables.
•
Manually Setting Variables
In Linux/Unix, when you're using the Bourne, Bash, or Korn shell, you can set OS variables manually from the OS
command line with the following
export
command:
$ export ORACLE_HOME=/orahome/app/oracle/product/12.1.0.1/db_1
$ export ORACLE_SID=O12C
$ export LD_LIBRARY_PATH=/usr/lib:$ORACLE_HOME/lib
$ export PATH=$ORACLE_HOME/bin:$PATH
Note that the prior commands are for my particular development environment; you'll need to adjust those to
match the Oracle home and database name used in your environment.
For the C or
tcsh
shell, use the
setenv
command to set variables:
$ setenv ORACLE_HOME <path>
$ setenv ORACLE_SID <sid>
$ setenv LD_LIBRARY_PATH <path>
$ setenv PATH <path>
Another way that DBAs set these variables is by placing the previous
export
or
setenv
commands into a Linux/Unix
startup file, such as
.bash_profile
,
.bashrc
, or
.profile
. That way, the variables are automatically set upon login.
However, manually setting OS variables (either from the command line or by hard-coding values into a startup
file) isn't the optimal way to instantiate these variables. For example, if you have multiple databases with multiple
Oracle homes on a box, manually setting these variables quickly becomes unwieldy and not very maintainable.