Lesson 3 | The NLS_LANG Parameter |
Objective | Select a runtime environment for Oracle |
Oracle NLS_LANG Parameter
A user can set a language environment for his or her own runtime environment through the use of the
NLS_LANG
parameter.
The `NLS_LANG` parameter is an important environment variable in Oracle that specifies the language, territory, and character set used by a client application. It affects how data is displayed, stored, and interpreted in a particular session. Here's how a user can set the `NLS_LANG` parameter for their runtime environment:
- Understanding `NLS_LANG` Structure:
The `NLS_LANG` parameter has the following structure:
NLS_LANG = language_territory.characterset
- `language`: Specifies the language for Oracle messages and day/month names. Example: `AMERICAN`, `FRENCH`.
- `territory`: Defines the conventions for date and numeric formats. Example: `AMERICA`, `FRANCE`.
- `characterset`: Specifies the character set used by the client application. Example: `WE8ISO8859P1`, `AL32UTF8`.
- Setting the `NLS_LANG` Parameter:
The `NLS_LANG` parameter can be set in the environment of the operating system, typically before starting the Oracle client application. Here’s how to do it on different operating systems:
On Unix/Linux:
You can set `NLS_LANG` in the shell environment using the `export` command:
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
On Windows: You can set `NLS_LANG` in the Command Prompt or permanently in the System Environment Variables:
Using Command Prompt:
cmd
set NLS_LANG=AMERICAN_AMERICA.AL32UTF8
Using System Environment Variables:
- Go to Control Panel > System > Advanced System Settings.
- Click on "Environment Variables".
- Under "System Variables" or "User Variables", click "New".
- Add `NLS_LANG` as the variable name and the desired value (e.g., `AMERICAN_AMERICA.AL32UTF8`) as the variable value.
-
Verifying the Setting: After setting `NLS_LANG`, you can verify that it is correctly set by running:
On Unix/Linux:
echo $NLS_LANG
On Windows: (cmd)
echo %NLS_LANG%
- Impact of `NLS_LANG`:
- Language: Determines the language for Oracle messages and the day and month names.
- Territory: Influences default date and numeric formats.
- Character Set: Defines the character encoding used by the client, ensuring that characters are correctly interpreted and stored.
- Example of Use: If you want your client environment to use American English with U.S. date formats and UTF-8 character encoding, you would set:
NLS_LANG=AMERICAN_AMERICA.AL32UTF8
This setup would ensure that your Oracle session handles data according to these regional settings and character encoding.
By properly setting `NLS_LANG`, users can ensure that their Oracle client applications interact correctly with the database, particularly in terms of language, territory-based formatting, and character set compatibility.
Component of NLS_LANG
There are three components of the
NLS_LANG
parameter:
- Language determines the language used by Oracle for error messages, day names, and month names.
- Territory determines the local conventions, such as date formats and currency symbols.
- Charset indicates the actual character set used by the client.
The
language and
territory portions of the parameter are optional. If a language or territory is not specified, these portions default to American. However, if you have a
language setting, you must also have a
territory setting and separate the two with an underscore. The
territory value is separated from the
charset value by a period.
Other National Language Parameters
You can use a number of other national language parameters to indicate specific attributes of the national language setting:
NLS_CALENDAR
indicates the calendar system used for the language.
NLS_CURRENCY
indicates the local currency symbol.
NLS_DATE_FORMAT
indicates the local date format.
NLS_DATE_LANGUAGE
indicates the default language used for dates.
NLS_ISO_CURRENCY
indicates the ISO international currency symbol.
NLS_SORT
indicates the sort order for the language.
NLS_CALENDAR specifies which calendar system Oracle uses. It can have one of the following values:
- Arabic Hijrah
- English Hijrah
- Gregorian
- Japanese Imperial
- Persian
- ROC Official (Republic of China)
- Thai Buddha
For example, suppose NLS_CALENDAR is set to "Japanese Imperial", the date format is "E YY-MM-DD".
("E" is the date format element for the abbreviated era name.) If the date is May 15, 1997, then the SYSDATE is displayed as follows:
SELECT SYSDATE FROM DUAL;
SYSDATE
--------
H 09-05-15
Each of these can be set in the Oracle initialization file or on a session-by-session basis.
You do not have to set any of them unless you wish their values to be different from the normal values for
NLS_LANGUAGE
and
NLS_TERRITORY
.
In the next lesson, you will learn about character sets, which determine how data is stored and interpreted in the Oracle database.
National Language Support - Quiz
