This topic discusses how to set up a globalization support environment. It includes the following topics:
NLS (National Language Support) parameters determine the locale-specific behavior on both the client and the server. NLS parameters can be specified several ways. In this guide, altering parameters for the user session and overriding the parameters in SQL functions are discussed. Both of these techniques accomplished through the use of SQL statements.
You can alter the NLS parameters settings by:
Setting NLS parameters in an ALTER SESSION statement to override the default values that are set for the session in the initialization parameter file, or that are set by the client with environment variables. For example:
ALTER SESSION SET NLS_SORT = french;
Note that the changes that you make with ALTER SESSION apply only to the current user session and are not present the next time you log in.
|
See Also:
|
Using NLS parameters within a SQL function to override the default values that are set for the session in the initialization parameter file, set for the client with environment variables, or set for the session by the ALTER SESSION statement. For example:
TO_CHAR(hiredate,'DD/MON/YYYY','nls_date_language = FRENCH')
|
See Also:
|
Additional methods for setting the NLS parameters require that you shutdown and restart the database. These techniques include the following:
Including parameters in the Oracle Database initialization parameter file to specify the default session NLS environment on the server side. For example:
NLS_TERRITORY = "CZECH REPUBLIC"
|
See Also: Oracle Database installation guide for Linux or Windows for information on setting globalization parameters and environmental variables. |
Using NLS environment variables on the client, which may be platform-dependent, to specify locale-dependent behavior for the client and also to override the default values set for the session in the initialization parameter file. For example, on a Linux system:
% setenv NLS_SORT FRENCH
|
See Also: Oracle Database installation guide for Linux or Windows for information on setting globalization parameters and environmental variables. |
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.
The NLS_LANG parameter sets the language and territory environment used by both the server session (for example, SQL command execution) and the client application (for example, display formatting in Oracle tools).
You might want to modify the NLS environment dynamically during the session. To do so, you can use the ALTER SESSION statement to change NLS_LANGUAGE, NLS_TERRITORY, and other NLS parameters.
|
Note: You cannot modify the setting for the client character set with theALTER SESSION statement. |
The ALTER SESSION statement modifies only the session environment. The local client NLS environment is not modified, unless the client explicitly retrieves the new settings and modifies its local environment.
|
See Also:
|
Setting different NLS parameters for local territories allows the database session to use different cultural settings. For example, you can set the euro (EUR) as the primary currency and the Japanese yen (JPY) as the secondary currency for a given database session even when the territory is defined as AMERICA.
This topic contains information about the following parameters:
The NLS_LANGUAGE parameter can be set to any valid language name and the default is derived from the NLS_LANG setting. NLS_LANGUAGE specifies the default conventions for the following session characteristics:
Language for server messages
Language for day and month names and their abbreviations (specified in the SQL functions TO_CHAR and TO_DATE)
Symbols for equivalents of AM, PM, AD, and BC.
Default sorting sequence for character data when ORDER BY is specified. (GROUP BY uses a binary sort unless ORDER BY is specified.)
Example: NLS_LANGUAGE=ITALIAN and Example: NLS_LANGUAGE=GERMAN show the results from setting NLS_LANGUAGE to different values. In Example: NLS_LANGUAGE=ITALIAN, the ALTER SESSION statement is issued to set NLS_LANGUAGE to Italian.
NLS_LANGUAGE=ITALIAN
ALTER SESSION SET NLS_LANGUAGE=Italian; -- enter a SELECT to check the format of the output after the ALTER SESSION SELECT last_name, hire_date, ROUND(salary/8,2) salary FROM employees WHERE employee_id IN (111, 112, 113);
You should see results similar to the following:
LAST_NAME HIRE_DATE SALARY------------------------- --------- ----------Sciarra 30-SET-97 962.5Urman 07-MAR-98 975Popp 07-DIC-99 862.5Note that the month name abbreviations are in Italian.
In Example: NLS_LANGUAGE=GERMAN, the ALTER SESSION statement is issued to change the language to German.
NLS_LANGUAGE=GERMAN
ALTER SESSION SET NLS_LANGUAGE=German;
SELECT last_name, hire_date, ROUND(salary/8,2) salary FROM employees
WHERE employee_id IN (111, 112, 113);
You should see results similar to the following:
LAST_NAME HIRE_DATE SALARY------------------------- --------- ----------Sciarra 30-SEP-97 962.5Urman 07-MRZ-98 975Popp 07-DEZ-99 862.5Note that the language of the month abbreviations has changed to German.
|
See Also:
|
The NLS_TERRITORY parameter can be set to any valid territory name and the default is derived from the NLS_LANG setting. NLS_TERRITORY specifies the conventions for the following default date and numeric formatting characteristics:
Date format
Decimal character and group separator
Local currency symbol
ISO currency symbol
Dual currency symbol
The territory can be modified dynamically during the session by specifying the new NLS_TERRITORY value in an ALTER SESSION statement. For example, to change the territory to France during a session, issue the following ALTER SESSION statement:
ALTER SESSION SET NLS_TERRITORY = France;
Modifying NLS_TERRITORY resets all derived NLS session parameters to default values for the new territory. Example: NLS_LANGUAGE=AMERICAN, NLS_TERRITORY=AMERICA and Example: NLS_LANGUAGE=AMERICAN, NLS_TERRITORY=GERMANY show behavior that results from different settings of NLS_TERRITORY and NLS_LANGUAGE.
NLS_LANGUAGE=AMERICAN, NLS_TERRITORY=AMERICA
-- set NLS_LANAGUAGE and NLS_TERRITORY
ALTER SESSION SET NLS_LANGUAGE = American NLS_TERRITORY = America;
-- enter the following SELECT to view the format of the output for currency
SELECT TO_CHAR(salary,'L99G999D99') salary FROM employees
WHERE employee_id IN (100, 101, 102);
When NLS_TERRITORY is set to AMERICA and NLS_LANGUAGE is set to AMERICAN, results similar to the following should appear:
SALARY-------------------- $24,000.00 $17,000.00 $17,000.00In Example: NLS_LANGUAGE=AMERICAN, NLS_TERRITORY=GERMANY an ALTER SESSION statement is issued to change the territory to Germany.
NLS_LANGUAGE=AMERICAN, NLS_TERRITORY=GERMANY
-- set NLS_TERRITORY to Germany for this session
ALTER SESSION SET NLS_TERRITORY = Germany;
SELECT TO_CHAR(salary,'L99G999D99') salary FROM employees
WHERE employee_id IN (100, 101, 102);
You should see results similar to the following:
SALARY------------------- €24.000,00 €17.000,00 €17.000,00Note that the currency symbol has changed from $ to €. The numbers have not changed because the underlying data is the same.
|
See Also:
|
Oracle enables you to control the display of date and time, allowing different conventions for displaying the hour, day, month, and year to be handled in local formats. For example, in the United Kingdom, the date is displayed using the DD/MM/YYYY format, while China commonly uses the YYYY-MM-DD format.
This topic contains the following topics:
Different date formats are shown in Table: Examples of Short Date Formats.
Examples of Short Date Formats
| Country | Description | Example |
|---|---|---|
|
Estonia |
dd.mm.yyyy |
28.02.2005 |
|
Germany |
dd.mm.rr |
28.02.05 |
|
China |
yyyy-mm-dd |
2005-02-28 |
|
UK |
dd/mm/yyyy |
28/02/2005 |
|
US |
mm/dd/yyyy |
02/28/2005 |
This topic includes the following parameters:
The NLS_DATE_FORMAT parameter defines the default date format to use with the TO_CHAR and TO_DATE functions. The NLS_TERRITORY parameter determines the default value of NLS_DATE_FORMAT. The value of NLS_DATE_FORMAT can be any valid date format mask. For example:
NLS_DATE_FORMAT = "MM/DD/YYYY"
The Oracle default date format may not always corresponds to the cultural specific convention used in a given territory. You can utilize the short date and long date format in SQL, using the 'DS' and 'DL' format masks respectively, to obtain dates in a more localized formats. The examples in this topic show the differences between some of the date formats.
Using the Default, Short, and Long Date Formats
-- Use an ALTER SESSION statement to change the territory to America, -- and the language to American ALTER SESSION SET NLS_TERRITORY = America NLS_LANGUAGE = American; -- After the session is altered, select the dates with the format masks SELECT hire_date, TO_CHAR(hire_date,'DS') "Short", TO_CHAR(hire_date,'DL') "Long" FROM employees WHERE employee_id IN (111, 112, 113);
The results of the query in Example: Using the Default, Short, and Long Date Formats are similar to the following:
HIRE_DATE Short Long--------- ---------- -----------------------------30-SEP-97 9/30/1997 Tuesday, September 30, 199707-MAR-98 3/7/1998 Saturday, March 07, 199807-DEC-99 12/7/1999 Tuesday, December 07, 1999To add string literals to the date format, enclose the string literal with double quotes. Note that when double quotes are included in the date format, the entire value must be enclosed by single quotes. For example:
NLS_DATE_FORMAT = '"Date: "MM/DD/YYYY'
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 default date format (NLS_DATE_FORMAT)
Example: NLS_DATE_LANGUAGE=FRENCH, Month and Day Names shows how to use NLS_DATE_LANGUAGE to set the date language to French.
NLS_DATE_LANGUAGE=FRENCH, Month and Day Names
-- set NLS_DATE_LANAGUAGE for this user session ALTER SESSION SET NLS_DATE_LANGUAGE = FRENCH; -- display the current system date SELECT TO_CHAR(SYSDATE, 'Day:Dd Month yyyy') FROM DUAL;
You should see output similar to the following, depending on the current system date:
TO_CHAR(SYSDATE,'DAY:DDMON--------------------------Jeudi :06 Octobre 2005The default date format uses the month abbreviations determined by NLS_DATE_LANGUAGE. For example, if the default date format is DD-MON-YYYY and NLS_DATE_LANGUAGE = FRENCH, then insert a date as follows:
INSERT INTO table_name VALUES ('12-Févr.-1997');
|
See Also: Oracle Database SQL Language Reference for information on date format models |
Different time formats are shown in Table: Examples of Time Formats.
Examples of Time Formats
| Country | Description | Example |
|---|---|---|
|
Estonia |
hh24:mi:ss |
13:50:23 |
|
Germany |
hh24:mi:ss |
13:50:23 |
|
China |
hh24:mi:ss |
13:50:23 |
|
UK |
hh24:mi:ss |
13:50:23 |
|
US |
hh:mi:ssxff am |
1:50:23.555 PM |
This topic contains information about the following parameters:
NLS_TIMESTAMP_FORMAT defines the default date format for the TIMESTAMP and TIMESTAMP WITH LOCAL TIME ZONE data types. The NLS_TERRITORY parameter determines the default value of NLS_TIMESTAMP_FORMAT. The value of NLS_TIMESTAMP_FORMAT can be any valid datetime format mask.
The following example shows a value for NLS_TIMESTAMP_FORMAT:
NLS_TIMESTAMP_FORMAT = 'YYYY-MM-DD HH:MI:SS.FF'
NLS_TIMESTAMP_TZ_FORMAT defines the default date format for the TIMESTAMP and TIMESTAMP WITH LOCAL TIME ZONE data types. It is used with the TO_CHAR and TO_TIMESTAMP_TZ functions. The NLS_TERRITORY parameter determines the default value of NLS_TIMESTAMP_TZ_FORMAT. The value of NLS_TIMESTAMP_TZ_FORMAT can be any valid datetime format mask.
The format value must be surrounded by quotation marks. For example:
NLS_TIMESTAMP_TZ_FORMAT = 'YYYY-MM-DD HH:MI:SS.FF TZH:TZM'
In Example: Setting NLS_TIMESTAMP_TZ_FORMAT the TO_TIMESTAMP_TZ function uses the format value that was specified for NLS_TIMESTAMP_TZ_FORMAT.
Setting NLS_TIMESTAMP_TZ_FORMAT
-- display August 20, 2005 using the format of NLS_TIMPSTAMP_TZ_FORMAT
SELECT TO_TIMESTAMP_TZ('2005-08-20, 05:00:00.55 America/Los_Angeles',
'yyyy-mm-dd hh:mi:ss.ff TZR') "TIMESTAMP_TZ Format" FROM DUAL;
You should see output similar to the following:
TIMESTAMP_TZ Format--------------------------------------------------------20-AUG-05 05.00.00.550000000 AM AMERICA/LOS_ANGELESThis topic includes the following topics:
The following calendar information is stored for each territory:
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.
The first day of the week is determined by the NLS_TERRITORY parameter.
Some countries use week numbers 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.
To support the ISO standard, Oracle provides the IW date format element. It returns the ISO week number.
The first calendar week of the year is determined by the NLS_TERRITORY parameter.
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 each Imperial Era
ROC Official—uses the same number of months and days as Gregorian, 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
English Hijrah—has 12 months with 354 or 355 days
The calendar system is specified by the NLS_CALENDAR parameter.
The Islamic calendar 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.
Many different calendar systems are in use throughout the world. NLS_CALENDAR specifies which calendar system Oracle uses. The default value is Gregorian. The value can be any valid calendar format name.
NLS_CALENDAR can have one of the following values:
Arabic Hijrah
English Hijrah
Gregorian
Japanese Imperial
Persian
ROC Official (Republic of China)
Thai Buddha
In Example: NLS_CALENDAR='English Hijrah' NLS_CALENDAR is set to English Hijrah.
NLS_CALENDAR='English Hijrah'
-- set NLS_CALENDAR with ALTER SESSION ALTER SESSION SET NLS_CALENDAR='English Hijrah'; -- display the current system date SELECT SYSDATE FROM DUAL;
You should see output similar to the following, depending on the current system date:
SYSDATE--------------------24 Ramadan 1422This topic includes the following topics:
The database must know the number-formatting convention used in each session to interpret numeric strings correctly. For example, the database needs to know whether numbers are entered with a period or a comma as the decimal character (234.00 or 234,00). Similarly, applications must be able to display numeric information in the format expected at the client site.
Examples of numeric formats are shown in Table: Examples of Numeric Formats.
Examples of Numeric Formats
| Country | Numeric Formats |
|---|---|
|
Estonia |
1 234 567,89 |
|
Germany |
1.234.567,89 |
|
China |
1,234,567.89 |
|
UK |
1,234,567.89 |
|
US |
1,234,567.89 |
Numeric formats are derived from the setting of the NLS_TERRITORY parameter, but they can be overridden by the NLS_NUMERIC_CHARACTERS parameter.
The NLS_NUMERIC_CHARACTERS parameter specifies the decimal character and group separator. The group separator is the character that separates integer groups to show thousands and millions, for example. The group separator is the character returned by the G number format mask. The decimal character separates the integer and decimal parts of a number. Setting NLS_NUMERIC_CHARACTERS overrides the default values derived from the setting of NLS_TERRITORY. The value can be any two valid numeric characters for the decimal character and group separator.
Any character can be the decimal character or group separator. The two characters specified must be single-byte, and the characters must be different from each other. The characters cannot be any numeric character or any of the following characters: plus (+), hyphen (-), less than sign (<), greater than sign (>). Either character can be a space.
To set the decimal character to a comma and the grouping separator to a period, define NLS_NUMERIC_CHARACTERS as follows:
ALTER SESSION SET NLS_NUMERIC_CHARACTERS = ",.";
SQL statements can include numbers represented as numeric or text literals. Numeric literals are not enclosed in quotes. They are part of the SQL language syntax and always use a dot as the decimal character and never contain a group separator. Text literals are enclosed in single quotes. They are implicitly or explicitly converted to numbers, if required, according to the current NLS settings.
The following SELECT statement formats the number 4000 with the decimal character and group separator specified in the ALTER SESSION statement:
ALTER SESSION SET NLS_NUMERIC_CHARACTERS = ",."; SELECT TO_CHAR(4000, '9G999D99') FROM DUAL;
You should see output similar to the following:
TO_CHAR(4---------4.000,00Oracle enables you to define radix symbols and thousands separators by locales. For example, in the US, the decimal point is a dot (.), while it is a comma (,) in France. Because the amount $1,234 has different meanings in different countries, it is important to display the amount appropriately by locale.
This topic includes the following topics:
Different currency formats are used throughout the world. Some typical ones are shown in Table: Currency Format Examples.
NLS_CURRENCY specifies the character string returned by the L number format mask, the local currency symbol. Setting NLS_CURRENCY overrides the default setting defined implicitly by NLS_TERRITORY. The value can be any valid currency symbol string.
Displaying the Local Currency Symbol
-- select and format the salary column from employees SELECT TO_CHAR(salary, 'L099G999D99') "salary" FROM employees WHERE salary > 11000;
You should see output similar to the following:
SALARY--------------------- $024,000.00 $017,000.00 $017,000.00 $012,000.00 $014,000.00 $013,500.00 $012,000.00 $011,500.00 $013,000.00 $012,000.00NLS_ISO_CURRENCY specifies the character string returned by the C number format mask, the ISO currency symbol. Setting NLS_ISO_CURRENCY overrides the default value defined implicitly by NLS_TERRITORY. The value can be any valid string.
Local currency symbols can be ambiguous. For example, a dollar sign ($) can refer to US dollars or Australian dollars. ISO specifications define unique currency symbols for specific territories or countries. For example, the ISO currency symbol for the US dollar is USD. The ISO currency symbol for the Australian dollar is AUD.
NLS_ISO_CURRENCY has the same syntax as the NLS_TERRITORY parameter, and all supported territories are valid values.
To specify the ISO currency symbol for France, set NLS_ISO_CURRENCY as shown in Example: Setting NLS_ISO_CURRENCY.
Setting NLS_ISO_CURRENCY
-- set NLS_ISO_CURRENCY to France ALTER SESSION SET NLS_ISO_CURRENCY = FRANCE; -- display the salary of selected employees SELECT TO_CHAR(salary, 'C099G999D99') "Salary" FROM employees WHERE department_id = 60;
You should see output similar to the following:
Salary-------------------- EUR009,000.00 EUR006,000.00 EUR004,800.00 EUR004,800.00 EUR004,200.00Different languages have their own sorting rules. Some languages are collated according to the letter sequence in the alphabet, some according to the number of stroke counts in the letter, and some are ordered by the pronunciation of the words. Treatment of letter accents also differs among languages. For example, in Danish, Æ is sorted after Z, while Y and Ü are considered to be variants of the same letter.
You can define how to sort data by using linguistic sort parameters. The basic linguistic definition treats strings as sequences of independent characters.
This topic includes the following topics:
The NLS_SORT parameter specifies the collating sequence for ORDER BY queries. It overrides the default NLS_SORT value that is derived from NLS_LANGUAGE. The value of NLS_SORT can be BINARY or any valid linguistic sort name:
NLS_SORT = BINARY | sort_name
If the value is BINARY, then the collating sequence is based on the numeric code of the characters in the underlying encoding scheme. Depending on the data type, this will either be in the binary sequence order of the database character set or the national character set. If the value is a named linguistic sort, sorting is based on the order of the defined sort. Most, but not all, languages supported by the NLS_LANGUAGE parameter also support a linguistic sort with the same name.
You can set the NLS_SORT parameter to change the linguistic sorting behavior of the your SQL session. Spain traditionally treats ch, ll as well as ñ as letters of their own, ordered after c, l and n respectively. Example: Setting NLS_SORT to BINARY and Example: Setting NLS_SORT to Spanish illustrate the effect of using a Spanish sort against the employee names Chen and Chung. In Example: Setting NLS_SORT to BINARY, the NLS_SORT parameter is set to BINARY.
In Example: Setting NLS_SORT to BINARY, LIKE is used to specify the records to return with the query. For information on LIKE, see Restricting Data Using the WHERE Clause.
Setting NLS_SORT to BINARY
-- set the NLS_SORT for this user session ALTER SESSION SET NLS_SORT=binary; -- select the last name of those employees whose last name begin with C SELECT last_name FROM employees WHERE last_name LIKE 'C%' ORDER BY last_name;
The output of Example: Setting NLS_SORT to BINARY appears:
LAST_NAME--------------CabrioCambraultCambraultChenChungColmenaresIn Example: Setting NLS_SORT to Spanish, the NLS_SORT parameter is set to SPANISH_M.
Setting NLS_SORT to Spanish
-- set the NLS_SORT for this user session ALTER SESSION SET NLS_SORT=spanish_m; -- select the last name of those employees whose last name begin with C SELECT last_name FROM employees WHERE last_name LIKE 'C%' ORDER BY last_name;
The output of Example: Setting NLS_SORT to Spanish appears:
LAST_NAME--------------CabrioCambraultCambraultColmenaresChenChungNote that the order of last names in the output from the SELECT statement in Example: Setting NLS_SORT to BINARY and Example: Setting NLS_SORT to Spanish is different.
|
See Also:
|
When using comparison operators, characters are compared according to their binary codes in the designated encoding scheme. A character is greater than another if it has a higher binary code. Because the binary sequence of characters may not match the linguistic sequence for a particular language, such comparisons might not be linguistically correct.
The value of the NLS_COMP parameter affects the comparison behavior of SQL operations. The value can be BINARY (default) or LINGUISTIC. You can use NLS_COMP to avoid the cumbersome process of using the NLSSORT function in SQL statements when you want to perform a linguistic comparison instead of a binary comparison. When NLS_COMP is set to LINGUISTIC, SQL operations perform a linguistic comparison based on the value of NLS_SORT.
Example: Setting NLS_COMP to BINARY and Example: Setting NLS_COMP to BINARY illustrate the effect of performing a binary comparison follow by a Spanish linguistic sensitive comparison against the employee names. In Example: Setting NLS_COMP to BINARY the NLS_COMP parameter is set to BINARY while NLS_SORT is set to Spanish.
Setting NLS_COMP to BINARY
-- set NLS_SORT and NLS_COMP for this user session ALTER SESSION SET NLS_SORT=spanish_m NLS_COMP=binary; -- select the last name of those employees whose last name begin with C SELECT last_name FROM employees WHERE last_name LIKE 'C%';
The output of Example: Setting NLS_COMP to BINARY appears:
LAST_NAME--------------CabrioCambraultCambraultChenChungColmenaresIn Example: Setting NLS_COMP to BINARY the NLS_COMP parameter is set to LINGUISTIC while NLS_SORT is set to Spanish.
Setting NLS_COMP to BINARY
-- set NLS_SORT and NLS_COMP for this user session ALTER SESSION SET NLS_SORT=spanish_m NLS_COMP=linguistic; -- select the last name of those employees whose last name begin with C SELECT last_name FROM employees WHERE last_name LIKE 'C%';
The output of Example: Setting NLS_COMP to BINARY appears:
LAST_NAME--------------CabrioCambraultCambraultColmenaresNote the difference in the output of Example: Setting NLS_COMP to BINARY and Example: Setting NLS_COMP to BINARY. In Spanish ch is treated as a separate character following c so ch is excluded when a Spanish linguistic sensitive comparison is performed in Example: Setting NLS_COMP to BINARY.
Operations inside a database are sensitive to the case and the accents of the characters. Sometimes you might need to perform case-insensitive or accent-insensitive comparisons. Use the NLS_SORT session parameter to specify a case-insensitive or accent insensitive sort.
To specify a case-insensitive or accent-insensitive sort:
Append _CI to an Oracle sort name for a case-insensitive sort. For example:
BINARY_CI: accent sensitive and case insensitive binary sortGENERIC_M_CI: accent sensitive and case insensitive GENERIC_M sortAppend _AI to an Oracle sort name for an accent-insensitive and case-insensitive sort. For example:
BINARY_AI: accent insensitive and case insensitive binary sortFRENCH_M_AI: accent insensitive and case insensitive FRENCH_M sortIn single-byte character sets, the number of bytes and the number of characters in a string are the same. In multibyte character sets, a character or code point consists of one or more bytes. Calculating the number of characters based on byte lengths can be difficult in a variable-width character set. Calculating column lengths in bytes is called byte semantics, while measuring column lengths in characters is called character semantics.
Character semantics is useful for defining the storage requirements for multibyte strings of varying widths. For example, in a Unicode database (AL32UTF8), suppose that you need to define a VARCHAR2 column that can store up to five Chinese characters together with five English characters. Using byte semantics, this column requires 15 bytes for the Chinese characters, which are three bytes long, and 5 bytes for the English characters, which are one byte long, for a total of 20 bytes. Using character semantics, the column requires 10 characters.
The expressions in the following list use byte semantics. Note the BYTE qualifier in the VARCHAR2 expression and the B suffix in the SQL function name.
VARCHAR2(20 BYTE)
SUBSTRB(string, 1, 20)
The expressions in the following list use character semantics. Note the CHAR qualifier in the VARCHAR2 expression.
VARCHAR2(20 CHAR)
SUBSTR(string, 1, 20)
This topic includes the following topic:
The NLS_LENGTH_SEMANTICS parameter specifies BYTE (default) or CHAR semantics. By default, the character data types CHAR and VARCHAR2 are specified in bytes, not characters. Hence, the specification CHAR(20) in a table definition allows 20 bytes for storing character data.
NLS_LENGTH_SEMANTICS enables you to create CHAR, VARCHAR2, and LONG columns using either byte or character length semantics. NCHAR, NVARCHAR2, CLOB, and NCLOB columns are always character-based. Existing columns are not affected.
Example: Length Semantics and CREATE TABLE shows an example of creating a table. When the database character set is WE8MSWIN1252, the last_name column of the table can hold up to 10 Western European characters, occupying a maximum of 10 bytes. When the database character set is Unicode (AL32UTF8), last_name can still hold up to 10 Unicode characters regardless of the language; however, it can occupy a maximum of 40 bytes.
Length Semantics and CREATE TABLE
CREATE TABLE temp_employees_table ( employee_id NUMBER(4), last_name VARCHAR2(10 CHAR), job_id VARCHAR2(9), manager_id NUMBER(4), hire_date DATE, salary NUMBER(7,2), department_id NUMBER(2)) ;
|
See Also:
|