banner



How To Set Environment Variable For Oracle 12c In Linux

Exporting Variables

When a variable is set, it becomes available for use in the current session, but sometimes a variable may need to be made available for other programs that are run from the current session.  To accomplish this, use the export command.

A good example of this is setting the ORACLE_SID variable.

$ ORACLE_SID=TEST
$ export ORACLE_SID
By exporting the ORACLE_SID variable, other programs that are called from this session to retrieve the contents of the variable are allowed.  This variable is used to specify what database to connect to if SQL*Plus is started without specifying one.

Note: There is no need to export every variable that is created.  Only export variables if they need to be available to programs or scripts that are being run.

A list of all the currently exported variables can be obtained using the env command.

$ env

HOSTNAME=oelinux-test1.lifeaftercoffee.com
TERM=xterm-color
SHELL=/bin/bash
HISTSIZE=1000
USER=jemmons
ORACLE_SID=TEST
PATH=/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/jemmons/bin
PWD=/home/jemmons/notes
PS1=$
HOME=/home/jemmons
...

Above is a partial list of the exported variables that are likely to be seen in a command line session.  It can be seen that the variable that was just exported, ORACLE_SID, is listed.  The shell automatically sets many of the other variables listed.  Several of these will be shown in the next section.

Environment Variables

Environment variables are a set of variables that affect the behavior or describe the condition of the current command line session or other programs on the system.  Like other variables, they can be listed using set or viewed individually using echo.

$ echo $SHELL

/bin/bash

$ echo $PS1
$
$ echo $HOME

/home/jemmons

$ echo $ORACLE_SID

TEST

Some shells set and retrieve environment variables differently from other shell variables, but in bash and Bourne shells, there is no differentiation.

Note: Environment variables, variables that will have an effect on more than the current shell session, typically have names that are all UPPERCASE.  Variables such as counters, which are only used in the current session typically, have lowercase names.  This is a convention, not a steadfast rule, but it is good practice, especially when you begin shell scripting.

Some environment variables, like PATH or ORACLE_SID, will need to be updated.  Others like HOME or PWD are set by, and should only be updated by, the system.  Following is a list of some of the more important shell variables.

Variable Contains Update Notes

PATH

The binary search path The location of additional installed software may be added to the PATH, but be careful when removing a location.

MANPATH

The man page search path Additional locations where man pages can be found may be added.  If not set, the system-wide MANPATH will be used.

PS1

The command line prompt.  This is displayed at the beginning of each command line. This can be changed to the preference, but extremely long prompts may become cumbersome.

PS2

The secondary prompt.  This is displayed when multi-line commands are entered. This can be changed to the  preference but should be kept short and different from PS1.

HISTSIZE

The number of commands to track for retrieval by the history command. Typically defaults to 1000.  Can be set to another number if desired.

HOME

The location of the current user's home directory Do not update.  Set by shell.

OLDPWD

The previous working directory set before the last cd command. Do not update.  Set by the cd command.

ORACLE_SID

The SID of an Oracle database to be connected to. Can be set and exported, or set using the oraenv script.

ORACLE_HOME

The location where the database binaries are installed for the current database Should only be set or updated by the oraenv script.

Table 3.1:  Some Important Environment Variables

There are many more environment variables available and often software like Oracle will require certain settings.   More information about other environment variables can be found in the man pages for the specific shell.

Get the Complete Details on
Linux System Management for Oracle DBAs


The landmark book "Linux for the Oracle DBA: The Definitive Reference" provides comprehensive yet specific knowledge on administering Oracle on Linux.   A must-have reference for every DBA running or planning to run Oracle on a Linux platform.

Buy it for 30% off directly from the publisher.


Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata? Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just e-mail:

and include the URL for the page.


Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.

How To Set Environment Variable For Oracle 12c In Linux

Source: http://www.dba-oracle.com/t_linux_environment_variables.htm

Posted by: spurlocksathimpiou.blogspot.com

0 Response to "How To Set Environment Variable For Oracle 12c In Linux"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel