Skip Headers

Oracle® Database Globalization Support Guide
10g Release 1 (10.1)

Part Number B10749-01
< td align="center" valign="top">Go to Index
Index
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Master Index
Master Index
< a href="../../dcommon/html/feedback.htm">Go to Feedback page
Feedback

Go to previous page
Previous
Go to next page
Next
View PDF

3
Setting Up a Globalization Support Environment

This chapter tells how to set up a globalization support environment. It includes the following topics:

Setting NLS Parameters< /font>

NLS parameters determine the locale-specific behavior on both the cl ient and the server. NLS parameters can be specified in the following ways:

Table 3-1 shows the precedence order of the different methods of setting NLS parameters. Higher priority settings override lower priority settings. For example, a default value has the lowest priority and can be overridden by any other method.

Table 3-1 Methods of Setting NLS Parameters and Their Priorities  
Priority Method

1 (highest)

Explicitly set in SQL functions

2

Set by an ALTER SESSION statement

3

Set as an environm ent variable

4

Specified in the initialization parameter file

5

Default

Table 3-2 lists the available NLS parameters. Because the SQL function NLS parameters can be specified only with specif ic functions, the table does not show the SQL function scope.

Table 3-2 NLS Parameters  
Parameter Description Default Scope : I = Initialization Parameter File
E = Environment Variable
A = ALTER SESSION

NLS_CALENDAR

Calendar system

Gr egorian

I, E, A

NLS_COMP

< td class="Formal">

SQL, PL/SQL operator comparison

BINARY

I, E, A

NLS_CREDIT

Credit accounting symbol

Derived from NLS_TERRITORY

E

NLS_CURRENCY

Local currency symbol

Derived from NLS_TERRITORY

I, E, A

NLS_DATE_FORMAT

Date format

Der ived from NLS_TERRITORY

I, E, A

N LS_DATE_LANGUAGE

Language for day and month names

Derived from NLS_LANGUAGE

I, E, A

NLS_DEBIT

Debit accounting symbol

Derived from NLS_TERRI TORY

E

NLS_ISO_CURRENCY

< /td>

ISO international currency symbol

Derived from NLS_TERRITORY

I, E, A

NLS_LANG

See Also: "Choo sing a Locale with the NLS_LANG Environment Variable"

Language, territory, character set

AMERICAN_AMERICA.
US7ASCII

E

NLS_LA NGUAGE

Language

Derived from NLS_LANG

I, A

NLS_LENGTH_SEMANTICS

How strings are treated

BYTE

I, A

NLS_LIST_SEPARATOR

Character that separates items in a list

Derived fro m NLS_TERRITORY

E

NLS_MONETARY_CH ARACTERS

Monetary symbol for dollar and cents (or their equivalents)

Derived from NLS_TERRITORY

E

NLS_NCHAR_CONV_EXCP

Reports data loss during a character type conversion

FALSE

I, A

NLS_NUMERIC_CHARACTERS

Decimal character and group se parator

Derived from NLS_TERRITORY

I, E, A

NLS_SORT

Character sort sequence

Derived from < code>NLS_LANGUAGE

I, E, A

NLS_TERRITORY

Territory

Derived from NLS_LANG

I, A

NLS_TIMESTAMP_FORMAT

Timestamp

< td class="Formal">

Derived from NLS_TERRITORY

I, E, A

NLS_TIMESTAMP_TZ_FORMAT

Timestamp with time zone

Derived from NLS_TERRITORY

I, E, A

NLS_DUAL_CURRE NCY

Dual currency symbol

Derived from NLS_TERRITORY

I, E, A

Choosing a Locale with the NLS_LANG Environment Variable

A locale is a linguistic and cultural environment in which a system or program is running. Setting the NLS_LANG environment parameter is the simplest way to specify locale behavior for Oracle software. It sets the language and territory used by the client application and the database server. It also sets the client's character set, which is the character set for data entered or displayed by a client program.

NLS_LAN G is set as a local environment variable on UNIX platforms. NLS_LANG is set in the registry on Windows platforms.

The NLS_LANG parameter has three components: language, territory, and charact er set. Specify it in the following format, including the punctuation:

NLS_LANG = langu
age_territory.charset

For example, if the Oracle Installer d oes not populate NLS_LANG, then its value by default is AMERICAN_AMERICA.US7ASCII. The language is AM ERICAN, the territory is AMERICA, and the character set is US7ASCII.

Each component of the NLS_LANG parameter controls the operation of a subset of globalization support features :

  • language

    < /p>

    Specifies conventions such as the language used for Oracle messages, sorting, day names, and month names. Each sup ported language has a unique name; for example, AMERICAN, FRENCH, or GERMAN. The language argu ment specifies default values for the territory and character set arguments. If the language is not specified, then the value default s to AMERICAN.

  • territory

    Specifies conventions such as the default date, monetary, and numeric formats. Each supported terri tory has a unique name; for example, AMERICA, FRANCE, or CANADA. If the territory is not speci fied, then the value is derived from the language value.

  • charset

    Specifies the character set used by the client application (normally the Oracle character set that corresponds to the user's terminal character set or the OS character set). Each supported character set ha s a unique acronym, for example, US7ASCII, WE8ISO8859P1, WE8DEC, WE8MSWIN1252, or JA16EUC. Each language has a default character set associated with it.


    Note:

    All components of the NLS_LANG definition are optional; any item that is not specified uses its default value. If you sp ecify territory or character set, then you must include the preceding delimiter [underscore (_) for territory , period (.) for character set]. Otherwise, the value is parsed as a language name.

    For exam ple, to set only the territory portion of NLS_LANG, use the following format: NLS_LANG=_JAPAN


The three components of NLS_LANG can be specified in many combinations, as in the following examples:

NLS_LANG = AMERICAN_AMERICA.WE8MSWIN1252

NLS_LANG = FRENCH_CANADA.WE8ISO8859P1

NLS_L
ANG = JAPANESE_JAPAN.JA16EUC

Note that illogical combinations can be set but do not work properly. For example, the following specification tries to support Japanese by using a Western European char acter set:

NLS_LANG = JAPANESE_JAPAN.WE8ISO8859P1

Because the WE8ISO8859P1 character set does not support any Japanese characters, you cannot store or displ ay Japanese data if you use this definition for NLS_LANG.

The rest of this sec tion includes the following topics:

Specifying the Value of NLS_LANG

Set NLS_LANG as an environment variable. For example, in a UNIX operating system C-shell sess ion, you can specify the value of NLS_LANG by entering a statement similar to the following:

% setenv NLS_LANG FRENCH_FRANCE.WE8ISO8859P1

Becau se NLS_LANG is an environment variable, it is read by the client application at startup time. The client communicates th e information defined by NLS_LANG to the server when it connects to the database server.

The following examples show how date and number formats are affected by the NLS_LANG parameter.

Example 3-1 Setting NLS_LANG to American_America.WE8ISO88 59P1

Set NLS_LANG so that the language is AMERICAN, the territory is AMERICA, and the Oracle character set is WE8ISO8859P1:

% setenv NLS_LANG American_America.WE8ISO8859P1

Enter a SELECT statement:

SQL> SELECT last_name, hire_date, ROUND(salary/8,2) salary
FROM employees;

You should see results similar to the following:< /p>

LAST_NAME                 HIRE_DATE     SALARY
----------------------
--- --------- ----------
Sciarra                   30-SEP-97      962.5
Urman
         07-MAR-98        975
Popp                      07-DEC-99      862.5

Example 3-2 Setting NLS_LANG to French_France.WE8ISO8859P1

Set NLS_LANG so that the language is FRENCH, the territory is FRANCE, and the Oracle character set is WE8ISO8859P1:

% setenv NLS_LANG
 French_France.WE8ISO8859P1

Then the query shown in Example 3-1 returns the following output:

LAST_NAME
    HIRE_DAT     SALARY
------------------------- -------- ----------
Sciarra
       30/09/97      962,5
Urman                     07/03/98        975
Popp
          07/12/99      862,5

Note that the date format and the n umber format have changed. The numbers have not changed, because the underlying data is the same.

Overriding Language and Territory Specificat ions

The NLS_LANG parameter sets the language and terri tory environment used by both the server session (for example, SQL command execution) and the client application (for example, displa y formatting in Oracle tools). Using this parameter ensures that the language environments of both the database and the client applic ation are automatically the same.

The language and territory components of the NLS_LA NG parameter determine the default values for other detailed NLS parameters, such as date format, numeric characters, and ling uistic sorting. Each of these detailed parameters can be set in the client environment to override the default values if the NL S_LANG parameter has already been set.

If the NLS_LANG parameter is not set, then the server session environment remains initialized with values of NLS_LANGUAGE, NLS_TERRRITORY, and other NLS instance parameters from the initialization parameter file. You can modify these parameters and restart the instance to change the defaults.

You might want to modify the NLS environment dynamically during the s ession. To do so, you can use the ALTER SESSION statement to change NLS_LANGUAGE, NLS_TE RRITORY, and other NLS parameters.


Note:

You cannot modify the setting for the client character set with the ALTER SESSION statement.


The ALTER SESSION statement modifies only the session environment. The local client NLS environment is not modified, unless the client e xplicitly retrieves the new settings and modifies its local environment.

See Also:
< /a>

Locale Variants

Before Oracle Database 10g Release 1 (10.1), Oracle defined language and territory definitions separately. This resulted in the definition of a territory being independent of the language setti ng of the user. In Oracle Database 10g Release 1 (10.1), some territories can have different date, time, numb er, and monetary formats based on the language setting of a user. This type of language-dependent territory definition is called a lo cale variant.

For the variant to work properly, both NLS_TERRITORY and N LS_LANGUAGE must be specified. For example, if NLS_LANGUAGE is specified as DUTCH and NLS_TERR ITORY is not set, then the territory behavior is THE NETHERLANDS. If NLS_TERRITORY is set to B ELGIUM and NLS_LANGUAGE is not set or it is set to DUTCH, then date, time, number, and monetary form ats are based on DUTCH behavior. By contrast, if NLS_TERRITORY is set to BELGIUM and NLS _LANGUAGE is set to FRENCH, then date, time, number, and monetary formats are based on FRENCH behavi or.

Table 3-3 shows the territories that have been enhanced to support variations. Default territory behaviors are noted. They occur when NLS_LANGUAGE is not specified.

Table 3-3 Oracle Locale Variants  
Oracle Territory Oracle Langu age

BELGIUM

DUTCH (default)

BELGIUM

FRENCH

BELGIUM

GERMAN

CANADA

FRENCH (default)

< code>CANADA

ENGLISH

DJIBOUTI

FRENCH (default)

DJIBOUTI

ARABIC

FINLAND

FINLAND (defaul t)

FINLAND

SWEDISH

HONG KONG

TRADITIONAL CHINESE (default)

HONG KONG

ENGLISH

INDIA

ENGLISH (def ault)

INDI A

ASSAMESE

INDIA

BANGLA

< a name="1010624">

INDIA

GUJAR ATI

INDIA

HINDI

INDIA

KANNADA

INDIA

MA LAYALAM

< code>INDIA

MARATHI

INDIA

ORIYA

INDIA

PUNJABI

INDIA

TAMIL

INDIA

TELUGU

LUXEMBOURG

GERMAN (default)

LUXEMBOURG

FRENCH

SINGAPORE< /p>

ENGLISH (default)

SINGAPORE

< a name="1010674">

MALAY

SINGAPORE

SIMPLIFIED CHINESE

SINGAPORE

TAMIL

SWITZERLAND

< /td>

GERMAN (default)

SWITZERLAND

FRENCH

SWITZERLAND

ITALIAN

Should the NLS_LANG Setting Match the Database Character Set?

The NLS_LANG character set should reflect the setting of the operating system character set of the client. For example, if the database character set is AL32UTF8 and the client is running on a Windows operating system, then y ou should not set AL32UTF8 as the client character set in the NLS_LANG parameter because there are no UTF-8 WIN32 client s. Instead the NLS_LANG setting should reflect the code page of the client. For example, on an English Windows client, t he code page is 1252. An appropriate setting for NLS_LANG is AMERICAN_AMERICA.WE8MSWIN1252.

Setting NLS_LANG correctly allows proper conversion from the client operating system characte r set to the database character set. When these settings are the same, Oracle assumes that the data being sent or received is encoded in the same character set as the database character set, so no validation or conversion is performed. This can lead to corrupt data if the client code page and the database character set are different and conversions are necessary.

< /a>See Also:

Oracle Database Installation Guide for Windows for more information about commonly used values of the NLS_LANG parameter in Windows

NLS Database Parame ters

When a new database is created during the execution of the CREATE DATABASE statement, the NLS-related database configuration is established. The current NLS instance para meters are stored in the data dictionary along with the database and national character sets. The NLS instance parameters are read fr om the initialization parameter file at instance startup.

You can find the values for NLS p arameters by using:

NLS Data Dictio nary Views

Applications can check the session, instance, and databas e NLS parameters by querying the following data dictionary views:

  • NLS_SESSION_PARAMETERS shows the NLS parameters and their values for the session that is querying the view. It does not show information about the character set.
  • NLS_INSTANCE_PARAMETERS shows the current NLS instance parameters that have been explicitly set and the values of the NLS instance parameters.
  • NLS_DATABASE_PARAMETERS shows the values of the NLS parameters for the dat abase. The values are stored in the database.

NLS Dynamic Performance Views

Applications can check the following NLS dynamic performance views:

  • V$NLS_VALID_VALUES lists values for the following NLS parameters: NLS_LANGUAGE, NLS_SORT, NLS_TERRITORY, NLS_CHARACTERSET
  • V$NLS_P ARAMETERS shows current values of the following NLS parameters: NLS_CALENDAR, NLS_CHARACTERSET, NLS_CURRENCY, NLS_DATE_FORMAT, NLS_DATE_LANGUAGE, NLS_ISO_CURRENCY, NLS_LANGUAG E, NLS_NUMERIC_CHARACTERS, NLS_SORT, NLS_TERRITORY, NLS_NCHAR_CHARACTERSET , NLS_COMP, NLS_LENGTH_SEMANTICS, NLS_NCHAR_CONV_EXP, NLS_TIMESTAMP_FORMAT, NLS_TIMESTAMP_TZ_FORMAT, NLS_TIME_FORMAT, NLS_TIME_TZ_FORMAT

OCINlsGetInfo() Function

User applications can query client NLS settings with the OCINlsGetInfo() function.

See Also:

"Getting Locale In formation in OCI" for the description of OCINlsGetInfo()

Language a nd Territory Parameters

This section contains information about the following parameters:

NLS_LANGUAGE

Property Description< /font>

Parameter type

String

Parameter scope

Initialization parameter and AL TER SESSION

Default value

Derived from < code>NLS_LANG

Range of values

Any valid language name

NLS_LANGUAGE specifies the default con ventions for the following session characteristics:

  • Language f or server messages
  • Language for day and month names and their abbreviations (s pecified in the SQL functions TO_CHAR and TO_DATE)
  • S ymbols for equivalents of AM, PM, AD, and BC. (A.M., P.M., A.D., and B.C. are valid only if NLS_LANGUAGE is set to AMERICAN.)
  • Default sorting sequence for character data when ORDE R BY is specified. (GROUP BY uses a binary sort unless ORDER BY is specifi ed.)
  • Writing direction
  • Affirmative and negative response strings (for example, YES and NO)

The value specified for NLS_LANGUAGE in the initialization parameter file is the default for all sessions in th at instance. For example, to specify the default session language as French, the parameter should be set as follows:

NLS_LANGUAGE = FRENCH

Consider the foll owing server message:

ORA-00942:  table or view does not exist

When the language is French, the server message appears as follows:

ORA-00942:  table ou vue inexistante

Messages us ed by the server are stored in binary-format files that are placed in the $ORACLE_HOME/product_name/mesg directory, or the equivalent for your operating system. Multiple versions of these files can exist, one for each supported language, using the following filename convention:

<product_id><
;language_abbrev>.MSB

For example, the file containin g the server messages in French is called oraf.msb, because ORA is the product ID (<product_id> ) and F is the language abbreviation (<language_abbrev>) for French. The product_nam e is rdbms, so it is in the $ORACLE_HOME/rdbms/mesg directory.

If NLS_LANG is specified in the client environment, then the value of NLS_LANGUAGE in the initial ization parameter file is overridden at connection time.

Messages are stored in these files in one specific character set, depending on the language and the operating system. If this character set is different from the datab ase character set, then message text is automatically converted to the database character set. If necessary, it is then converted to the client character set if the client character set is different from the database character set. Hence, messages are displayed corr ectly at the user's terminal, subject to the limitations of character set conversion.

The l anguage-specific binary message files that are actually installed depend on the languages that the user specifies during product inst allation. Only the English binary message file and the language-specific binary message files specified by the user are installed.

The default value of NLS_LANGUAGE may be specific to the operating system. You c an alter the NLS_LANGUAGE parameter by changing its value in the initialization parameter file and then restarting the i nstance.

See Also: < a name="1006526">

Your operating system-specific Oracle documentation for more information about the default value of NLS_LANGUAGE

All messages and text should be in th e same language. For example, when you run an Oracle Developer application, the messages and boilerplate text that you see originate from three sources:

  • Messages from the server
  • Messages and boilerplate text generated by Oracle Forms
  • Messages and boilerplate text generated by the application

NLS_ LANGUAGE determines the language used for the first two kinds of text. The application is responsible for the language used in its messages and boilerplate text.

The following examples show behavior that results from setting NLS_LANGUAGE to different values.

Example 3-3 NLS_LANGUAGE=ITALIAN

Use the ALTER SESSION statement to set NLS_LANGUAGE to Italian:

ALTER SESSION SET NLS_LANGUAGE=Ital
ian;

Enter a SELECT statement:

<
a name="1006539">SQL> SELECT last_name, hire_date, ROUND(salary/8,2) salary FROM employees;

You should see results similar to the following:

LAST_NAM
E                 HIRE_DATE     SALARY
------------------------- --------- ----------
Sci
arra                   30-SET-97      962.5
Urman                     07-MAR-98        975
Popp                      07-DIC-99      862.5

Note that the mo nth name abbreviations are in Italian.

See Also:

"Overriding Default Values for NLS_ LANGUAGE and NLS_TERRITORY During a Session" for more information about using the ALTER SESSION statement

Example 3-4 NLS_LANGUAGE=GERMAN

Use the ALTER SESSION statem ent to change the language to German:

SQL> ALTER SESSION SET NLS_LANGUAGE=German;

Enter the same SELECT statement:

SQL> SELECT last_name, hire_date, ROUND(salary/8,2) salary FROM employees;

You should see results similar to the following:

LAST_NAME
              HIRE_DATE     SALARY
------------------------- --------- ----------
Sciarra
                   30-SEP-97      962.5
Urman                     07-MÄR-98        975
<
/a>Popp                      07-DEZ-99      862.5

Note that the l anguage of the month abbreviations has changed.

NLS_TERRITORY

Property Description

Parameter type

String

Parameter scope

Initialization parameter and ALTER SESSION

Default value

Derived from NLS_LANG

Range of values

Any valid territory name

NLS_TERRITORY specifies the conventions for the following default date and numeric formatting characterist ics:

  • Date format
  • Decimal character and group separator
  • Local currency symbol
  • ISO currency symbol
  • Dual curren cy symbol
  • First day of the week
  • Credit and debit symbols
  • ISO week flag
  • List separator

The value specified for NLS_TERRITORY in the initialization parameter file is the default for the instance. For example, to specify the default as France, the parame ter should be set as follows:

NLS_TERRITORY = FRANCE

When the territory is FRANCE, numbers are formatted using a comma as the decimal character .

You can alter the NLS_TERRITORY parameter by changing the value in the initi alization parameter file and then restarting the instance. The default value of NLS_TERRITORY can be specific to the ope rating system.

If NLS_LANG is specified in the client environment, then the va lue of NLS_TERRITORY in the initialization parameter file is overridden at connection time.

The territory can be modified dynamically during the session by specifying the new NLS_TERRITORY value in an ALTER SESSION statement. Modifying NLS_TERRITORY resets all derived NLS session parameters to default values for the new territory.

To change the territory to France during a session , issue the following ALTER SESSION statement:

ALTER SESSION SET NLS_TERRITORY
 = France;

The following examples show behavior that results from different settings of NLS_TERRITORY and NLS_LANGUAGE.

Example 3-5 NLS_LANGUAGE=AMERICAN, NLS_TERRITORY=AMERICA

Enter the following SELECT statement:

SQL> SELECT TO_CHAR(s
alary,'L99G999D99') salary FROM employees;

When NLS_TERRITO RY is set to AMERICA and NLS_LANGUAGE is set to AMERICAN, results similar to the follow ing should appear:

SALARY
--------------------

$24,000.00
$17,000.00
$17,000.00

Example 3-6 NLS_LANGUAGE=AMERICAN, NLS_TERRITORY=GERMANY

Use an ALTER SESSION statement to change the territory to Germany:


ALTER SESSION SET NLS_TERRITORY = Germany;
Session altered.

Enter the same SELECT statement as before:

SQL> SELECT
 TO_CHAR(salary,'L99G999D99') salary FROM employees;

You should s ee results similar to the following:

SALARY
--------------------
€24.000,00
€17.000,00
€17.000,00

Note that the currency symbol has changed from $ to €. The numbers hav e not changed because the underlying data is the same.

See Also:

"Overriding Default Values for NLS_LANGUAGE and NLS_TERRITORY During a Session" for more information about using the ALTER SESSION statement

Example 3-7 NLS_LANGUAGE=GERMAN, NLS_TERRITORY=GERMANY

Us e an ALTER SESSION statement to change the language to German:

ALTER SESSION S
ET NLS_LANGUAGE = German;
Sitzung wurde geändert.

Note that the server message now appears in German.

Enter the same SELECT statement as before:

SQL> SELECT TO_CHAR(salary,'L99G999D99') salary FROM employ
ees;

You should see the same results as in Example 3-6:

SALARY
--------------------
€24.000,00
€17.000,00
€17.000,00

Example 3-8 NLS_LANGUAGE=GERMAN, NLS_TERRITORY=AMERICA

Use an ALTER SESSION statement to change the territory to America:

ALTER SESSION SET NLS_TERRITORY = America;
Sitzung wurde geändert.

Enter the same SELECT statement as in the other examples:

SQL> SELECT TO_CHAR(salary,'L99G999D99') salary FROM employees;

You should see output similar to the following:

SAL
ARY
--------------------
$24,000.00
$17,000.00
$17,000.00

Note that the currency symbol changed from € to $ because the territory changed from Germany to America.

Overriding Default Values for NLS_LANGUAGE and NLS_TERRITORY During a S ession

Default values for NLS_LANGUAGE and NLS_TE RRITORY and default values for specific formatting parameters can be overridden during a session by using the ALTER SESSION statement.

Example 3 -9 NLS_LANG=ITALIAN_ITALY.WE8DEC

Set the NLS_LANG environment var iable so that the language is Italian, the territory is Italy, and the character set is WE8DEC:

% setenv NLS_LANG Italian_Italy.WE8DEC

Enter a SELECT< /code> statement:

SQL> SELECT last_name, hire_date, ROUND(salary/8,2) salary FROM employ
ees;

You should see output similar to the following:

LAST_NAME                 HIRE_DATE     SALARY
------------------------- --------
- ----------
Sciarra                   30-SET-97      962,5
Urman                     07-
MAR-98        975
Popp                      07-DIC-99      862,5

Note the language of the month abbreviations and the decimal character.

Example 3-10 Change Language, Date Format, and Decimal Character

< a name="1006712">

Use ALTER SESSION statements to change the language, the date format, and the decim al character:

SQL> ALTER SESSION SET NLS_LANGUAGE=german;

Session wurde geändert.

SQL> ALTER SESSION SET NLS_DATE_FORMAT='D
D.MON.YY';

Session wurde geändert.

SQL
> ALTER SESSION SET NLS_NUMERIC_CHARACTERS='.,';

Session wurde geändert.

Enter the SELECT statement shown in Example 3-9:

SQL> SELECT last_name, hire_date, ROUND(salary/8,2) salary
 FROM employees;

You should see output similar to the following:< /p>

LAST_NAME                 HIRE_DATE     SALARY
----------------------
--- --------- ----------
Sciarra                   30.SEP.97      962.5
Urman
         07.MÄR.98        975
Popp                      07.DEZ.99      862.5

Note that the language of the month abbreviations is German and the decimal character is a per iod.

The behavior of the NLS_LANG environment variable implicitly determines t he language environment of the database for each session. When a session connects to a database, an ALTER SESSION< /code> statement is automatically executed to set the values of the database parameters NLS_LANGUAGE and NLS_TERRI TORY to those specified by the language and territory arguments of NLS_LANG. If N LS_LANG is not defined, then no implicit ALTER SESSION statement is executed.

When NLS_LANG is defined, the implicit ALTER SESSION is executed for all i nstances to which the session connects, for both direct and indirect connections. If the values of NLS parameters are changed explici tly with ALTER SESSION during a session, then the changes are propagated to all instances to which that use r session is connected.

Date and Time Parameters

Oracle enables you to contro l the display of date and time. This section contains the following topics:

Date Formats

Different date formats are shown in Table 3-4.

Table 3-4 Date Formats  
< thead>
Country Description Example

Estonia

dd.mm.yyyy

28.02. 2003

Germany

dd-mm-rr

28-02-03

Ja pan

rr-mm-dd

03-02-28

UK

dd-mon-rr

28-Feb-03

US

dd-mon-rr

28-Feb-03

This section includes the follow ing parameters:

NLS_DATE_FORMAT< /h4>
Property Description

Parameter type

String

Parameter scope

Initialization parameter, environ ment variable, and ALTER SESSION

Default value

< p class="TB">Derived from NLS_TERRITORY

Range of values

Any valid date format mask

The NLS_DA TE_FORMAT parameter defines the default date format to use with the TO_CHAR and TO_DATE functions. T he NLS_TERRITORY parameter determines the default value of NLS_DATE_FORMAT. The value of NLS_DATE_FOR MAT can be any valid date format mask. For example:

NLS_DATE_FORMAT = "MM/DD/YYYY"
<
a name="1006844">

To add string literals to the date format, enclose the string lite ral with double quotes. Note that when double quotes are included in the date format, the entire value must be enclosed by single quo tes. For example:

NLS_DATE_FORMAT = '"Date: "MM/DD/YYYY'

Example 3-11 Setting the Date Format to Display Roman Numerals< /h4>

To set the default date format to display Roman numerals for the month, include the follow ing line in the initialization parameter file:

NLS_DATE_FORMAT = "DD RM YYYY"

Enter the following SELECT statement:

SELECT TO_CHAR(SYSDATE) currdate FROM dual;

You sh ould see the following output if today's date is February 12, 1997:

CURRDATE
---------
12 II 1997

The value of < code>NLS_DATE_FORMAT is stored in the internal date format. Each format element occupies two bytes, and each string occupies t he number of bytes in the string plus a terminator byte. Also, the entire format mask has a two-byte terminator. For example, "MM/DD/ YY" occupies 14 bytes internally because there are three format elements (month, day, and year), two 3-byte strings (the two slashes) , and the two-byte terminator for the format mask. The format for the value of NLS_DATE_FORMAT cannot exceed 24 bytes.

You can alter the default value of NLS_DATE_FORMAT by:

  • Changing its value in the initialization parameter file and then restarting the instan ce
  • Using an ALTER SESSION SET NLS _DATE_FORMAT statement

    See Also:

    Oracle Database SQL Reference for more information about date format elements and the ALTER SESSION statement

If a table or index is partitioned on a date c olumn, and if the date format specified by NLS_DATE_FORMAT does not specify the first two digits of the year, then you m ust use the TO_DATE function with a 4-character format mask for the year.

For example:

TO_DATE('11-jan-1997', 'dd-mon-yyyy')
See Also:

Oracle Database SQL Reference f or more information about partitioning tables and indexes and using TO_DATE

NLS_DATE_LANGUAGE

Property Description< /font>

Parameter type

String

Parameter scope

Initialization parameter, environment variable, ALTER SESSION, and SQL functions

Default value

Derived from NLS_LANGUAGE

Range of values

Any valid language name

The NLS_DATE_LANGUAGE parameter specifies the language for the day and month names produced by the TO_CHAR and TO_DATE functions. NLS_DATE_LANGUAGE overrides the language that is specified implicitly by NLS_LANGUAGE. NLS_DATE_LANGUAGE has the same syntax as the NLS_LANGUAGE parameter, and all supported languages are valid values.

NLS_DATE_LANGUAGE also determines the language used for:

  • Month and day abbreviations returned by the TO_CHAR and TO_DATE functions
  • Month and day abbreviations used by the defaul t date format (NLS_DATE_FORMAT)
  • Abbreviations for AM, PM, AD, and BC
  • Example 3-12 NLS_DATE_LANGUAGE=FRE NCH, Month and Day Names

    Set the date language to French:

    ALTER SESSION SET NLS_DATE_LANGUAGE = FRENCH
    
    

    Enter a SELECT statement:

    SELECT TO_CHAR(SYSDATE, 'Day:Dd Month yyyy') FROM
    dual;
    
    

    You should see output similar to the following:

    TO_CHAR(SYSDATE,'DAY:DDMONTHYYYY')
    ---------------------------------------------
    ---------------
    Vendredi:07 Décembre  2001
    
    

    When numbers are spelled in words using the TO_CHAR function, the English spelling is always used. For example, e nter the following SELECT statement:

    SQL> SELECT TO_CHAR(TO_DATE('12-Oct-20
    01'),'Day: ddspth Month') FROM dual;
    
    

    You should see output simila r to the following:

    TO_CHAR(TO_DATE('12-OCT-2001'),'DAY:DDSPTHMONTH')
    --------------------------------------------------------------------
    Vendredi: twelfth Octobre
    

    Example 3-13 NLS_DATE_LANGUAGE=FRENCH, Month and Day Abb reviations

    Month and day abbreviations are determined by NLS_DATE_LANGUA GE. Enter the following SELECT statement:

    SELECT TO_CHAR(SYSDATE, 'Dy:d
    d Mon yyyy') FROM dual;
    
    

    You should see output similar to the foll owing:

    TO_CHAR(SYSDATE,'DY:DDMO
    ------------------------
    Ve:07 Dec 2001
    

    Example 3-14 NLS _DATE_LANGUAGE=FRENCH, Default Date Format

    The default date format uses the mo nth abbreviations determined by NLS_DATE_LANGUAGE. For example, if the default date format is DD-MON-YYYY, then insert a date as follows:

    INSERT INTO tablename VALUES ('12-Fév-1997')
    ;
    

    Time Formats

    Different time fo rmats are shown in Table 3-5.

    Table 3-5 Time Formats  
    Country Description Example

    Estonia

    hh24:mi:ss

    13:50:23

    Germ any

    hh24:mi:ss

    13:50:23

    Japan

    hh24:mi:ss

    13:50:23

    UK

    hh24:mi:ss

    13:50:23

    US

    hh:mi:ssxff am

    1:50:23.555 PM

    This sectio n contains information about the following parameters:

    NLS_TIMESTAMP_FORMAT

    Property Description

    Parameter type

    String

    Parameter scope

    Initialization parameter, environment variable, and ALTER SESSION

    Def ault value

    Derived from NLS_TERRITORY

    Range of values

    Any valid datetime format mask

    NLS_TIMESTAMP_FORMAT defines the default date format for the TIMESTAMP and TIMESTAMP WITH LOCAL TIME ZONE datatypes. The following example shows a value for N LS_TIMESTAMP_FORMAT:

    NLS_TIMESTAMP_FORMAT  = 'YYYY-MM-DD HH:MI:SS.FF'
    

    Example 3-15 Timestamp Format

    SQL> SELECT TO_TIMESTAMP('11-nov-2000 01:00:00.336', 'dd-mon-yyyy hh:mi:ss.ff')
    
    <
    /a>FROM dual;
    

    You should see output similar to the following:

    TO_TIMESTAMP('11-NOV-200001:00:00.336','DD-MON-YYYYHH:MI:SS.FF')
    --------
    -------------------------------------------------------------------
    11-NOV-00 01:00:00.336000000
    
    

    You can specify the value of NLS_TIMESTAMP_FORMAT by setting it in the initialization parameter file. You can specify its value for a client as a client environment variable.

    You can also alter the value of NLS_TIMESTAMP_FORMAT by:

    • Changing its value in the initialization parameter file and then restarting the instance
    • Using the ALTER SESSION SET NLS_TIMESTAMP_FORMAT statement

      See Also:

      Ora cle Database SQL Reference for more information about the TO_TIMESTAMP function and the ALTER SESSION statement

    NLS_TIMESTAMP_TZ_FORMAT

    Property Description

    Parameter type

    String

    Parameter scope

    < a name="1009119">

    Initialization parameter, environment variable, and ALTER SESSION

    Default value

    Derived from NLS_TERRITORY

    R ange of values

    Any valid datetime format mask

    NLS_TIMESTAMP_TZ_FORMAT defines the default date format for th e TIMESTAMP and TIMESTAMP WITH LOCAL TIME ZONE datatypes. It is used with the TO_CHAR and TO_TIMESTAMP_TZ functions.

    You can specify the value of NLS_TIMESTAMP_TZ_FOR MAT by setting it in the initialization parameter file. You can specify its value for a client as a client environment variabl e.

    Example 3-16 Setting NLS_TIMESTAMP_TZ_FOR MAT

    The format value must be surrounded by quotation marks. For example:

    < pre class="CE">NLS_TIMESTAMP_TZ_FORMAT = 'YYYY-MM-DD HH:MI:SS.FF TZH:TZM'

    The following example of the TO_TIMESTAMP_TZ function uses the format value that was spe cified for NLS_TIMESTAMP_TZ_FORMAT:

    SQL> SELECT TO_TIMESTAMP_TZ('2000-08-20
    , 05:00:00.55 America/Los_Angeles', 
    'yyyy-mm-dd hh:mi:ss.ff TZR') FROM dual;
    
    
    < p class="BP">You should see output similar to the following:

    TO_TIMESTAMP_TZ('2000-08-20,05
    :00:00.55AMERICA/LOS_ANGELES','YYYY-MM-DDHH:M
    -----------------------------------------------------------------
    ----------
    20-AUG-00 05:00:00.550000000 AM AMERICA/LOS_ANGELES
    
    

    You can change the value of NLS_TIMESTAMP_TZ_FORMAT by:

    • Changing its value in the initialization parameter file and then restarting the instance
    • Using the ALTER SESSION statement.
    < !--TOC=h1-"1007192"-->
    See Also:

    Calendar Definitions

    This s ection includes the following topics:

    Calen dar Formats

    The following calendar information is stored for each te rritory:

    First Day of the Week

    Some cultures consider Sunday to be the first day of the week. Others consider Monday to be the first day of the week. A German calendar starts with Monday, as shown in Table 3-6.

    Table 3-6 German Calendar Example: March 1998

    28

    < /tr>
    Mo Di< /th> Mi Do Fr Sa So

    -

    -

    -

    -

    -

    -

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

    13

    14

    15

    16

    17

    18

    19

    20

    21

    22

    23

    24

    25

    26

    27

    29

    30

    31

    -

    -

    -

    -

    -

    The first day of the week is determined by the NLS_TERRITORY parameter.

    See Also:

    "NLS_TERRITORY"

    First Calendar Week of the Year

    Some countries use week numbe rs for scheduling, planning, and bookkeeping. Oracle supports this convention. In the ISO standard, the week number can be different from the week number of the calendar year. For example, 1st Jan 1988 is in ISO week number 53 of 1987. An ISO week always starts on a Monday and ends on a Sunday.

    • If January 1 falls on a Friday, Saturday, or Sunday, then the ISO week that includes January 1 is the last week of the previous year, because most of the days in the week belong to the previous year.
    • If January 1 falls on a Monday, Tuesday, We dnesday, or Thursday, then the ISO week is the first week of the new year, because most of the days in the week belong to the new yea r.

    To support the ISO standard, Oracle provides the IW date format element. It return s the ISO week number.

    Table 3-7 shows an example i n which January 1 occurs in a week that has four or more days in the first calendar week of the year. The week containing January 1 i s the first ISO week of 1998.

    Table 3-7 First ISO Week of the Year: Example 1, January 1998  

    First ISO week of 1998

    Mo Tu We Th Fr Sa Su ISO Week

    -

    -

    -

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    Second ISO week of 1998

    12

    13

    14

    15

    16

    17

    18

    Third ISO week of 1998

    19

    20

    21

    22

    23

    24

    25

    Fourth ISO week of 1998

    26

    27

    28

    29

    30

    31

    -

    Fifth ISO week of 1998

    Table 3-8 shows an example in which January 1 occurs in a week that has three or fewer days in the first calendar week of the year. The week containing January 1 is the 53rd ISO week of 1998, and the following week is the first ISO week of 1999.

    Table 3-8 First ISO W eek of the Year: Example 2, January 1999   < th class="Formal" align="left" valign="bottom" scope="col">T u
    Mo We Th Fr Sa Su < /a> ISO Week

    -

    -

    -

    < p class="TB">-

    1

    2

    3

    < /a>

    Fifty-third ISO week of 1998

    4

    5

    6

    7

    8

    9

    10

    First ISO week of 1999< /p>

    11

    12

    13

    14

    15

    16

    1 7

    Second ISO week of 1999

    18

    19

    20

    21

    22

    23

    24

    Third ISO week of 1999

    25

    26

    27

    28

    29

    30

    31

    Fourth ISO week of 1999

    The first calendar week of the year is determined by the NLS_TERRITORY parameter.

    See Also:

    "NLS_TERRITORY"

    Number of Days and Months in a Year

    Oracle supports six calendar systems in addition to Gregorian, the default:

    • Japanese Imperial--uses the same number of months and days as Gregorian, but the year starts with the beginning of e ach Imperial Era
    • ROC Official--uses the same number of months and days as Greg orian, but the year starts with the founding of the Republic of China
    • Persian- -has 31 days for each of the first six months. The next five months have 30 days each. The last month has either 29 days or 30 days ( leap year).
    • Thai Buddha--uses a Buddhist calendar
    • Arabic Hijrah--has 12 months with 354 or 355 days
    • E nglish Hijrah--has 12 months with 354 or 355 days

    The calendar system is specified by the NLS_CALENDAR parameter.

    See Also:

    "NLS_CALENDAR"

    First Year of Era

    The Islamic c alendar starts from the year of the Hegira.

    The Japanese Imperial calendar starts from the beginning of an Emperor's reign. For example, 1998 is the tenth year of the Heisei era. It should be noted, however, that the Gregori an system is also widely understood in Japan, so both 98 and Heisei 10 can be used to represent 1998.

    NLS_CALENDAR

    Property Description

    Parameter type

    String

    Parameter sco pe

    Initialization parameter, environment variable, ALTER SESSION, and SQL functions

    Default value

    Gregorian

    Range of values

    Any valid cal endar format name

    Many different calendar systems are in use thro ughout the world. NLS_CALENDAR specifies which calendar system Oracle uses.

    NLS_CALENDAR can have one of the following values: