Lesson 2 | How Oracle implements National Language Support |
Objective | Understand how Oracle supports Foreign Languages |
How Oracle implements National Language Support and supports Foreign Languages
There are thousands of languages in the world. All these languages are different in the words and syntax they use, and many of these languages use different alphabets and character sets. As a global product, Oracle gives you the ability to support many different languages and character sets. Oracle supports language-dependent data and language-independent functions.
- Language-dependent Data:
Once a piece of data is stored in the Oracle database, it is meant to be stored securely forever. Because of this, Oracle uses a particular character set to store the data.
This character set is responsible for creating binary representations of the data in the database. Oracle can store the characters in the database whether a language uses a relatively small alphabet that can be stored in a single byte, like English, or a more complex representation that can use multiple bytes for each character, such as Chinese or Japanese.
Language-independent Functions and Support
The data in the database is different from the language used by an end user. You may have a situation where an end user wants to be able to store data in one language, yet requires the use of functions or the delivery of error messages in a different language. Even more common is the scenario where a single database will be used by individuals who understand different languages. Oracle allows each user to specify his or her own language preference. A single Oracle database can, for instance, deliver error messages in many different languages simultaneously. Although the interpretation of data is fixed to a particular language, the use of that data is not. In the next lesson, you will be introduced to the parameters used to determine how Oracle handles national language characters in the runtime environment.
The `NLS_LENGTH_SEMANTICS` parameter still exists and is supported in Oracle 19c.
This parameter controls whether the length semantics for `CHAR` and `VARCHAR2` data types are measured in bytes or characters. The two possible values are:
- `BYTE`: The length of the column is specified in bytes. This is the default value.
- `CHAR`: The length of the column is specified in characters, which is useful in multibyte character set environments.
Using `NLS_LENGTH_SEMANTICS` can be particularly important in applications that handle multilingual data, where the difference between byte length and character length can have significant implications for storage and processing.
You can change this parameter at the session level using `ALTER SESSION`, allowing flexibility depending on the needs of the specific session or operation.
NLS_LENGTH_SEMANTICS
Property |
Description |
Parameter type |
String |
Syntax |
NLS_LENGTH_SEMANTICS = string
Example: NLS_LENGTH_SEMANTICS = 'CHAR'
|
Default value |
BYTE |
Modifiable |
ALTER SESSION |
Range of values |
BYTE | CHAR |
NLS_LENGTH_SEMANTICS enables you to create CHAR and VARCHAR2 columns using either byte or character length semantics.
Existing columns are not affected. NCHAR, NVARCHAR2, CLOB, and NCLOB columns are always character-based. You may be required to use byte semantics in order to maintain compatibility with existing applications.
NLS_LENGTH_SEMANTICS does not apply to tables in SYS and SYSTEM. The data dictionary always uses byte semantics.