Oracle Character Set

Source: Internet
Author: User

Http://www.linuxidc.com/Linux/2011-11/47383p2.htm

What is the Oracle character set
The Oracle character set is a collection of symbols that interpret a byte of data, have a size, and have a mutual containment relationship. ORACLE's support for national language architectures allows you to store, process, and retrieve data using localized languages. It enables database Tools, error messages, sort order, date, time, currency, numbers, and calendars to automatically adapt to localized languages and platforms.
The most important parameter that affects the Oracle database character set is the Nls_lang parameter.
Its format is as follows: Nls_lang = Language_territory.charset
It has three components (language, geography, and character set), each of which controls the characteristics of the NLS subset.
which
Language: Specifies the language of the server message, whether the effect prompt is Chinese or English
Territory: Specifies the date and number format of the server,
Charset: Specifies the character set.
such as: AMERICAN _ AMERICA. Zhs16gbk
From the composition of Nls_lang we can see that the real impact of the database character set is actually the third part.
So the character set between the two databases can import and export data to each other as long as the third part, the only thing that affects the message is the Chinese or English.

The database server character Set select * from Nls_database_parameters, which is derived from props$, is the character set representing the database.
The client character set environment, select * from Nls_instance_parameters, is derived from V$parameter, which represents the setting of the client's character set, which may be a parameter file, an environment variable, or a registry
Session Character Set Environment select * from Nls_session_parameters, which originates from V$nls_parameters, represents the session's own settings, which may be the session's environment variable or alter session completion, If the session does not have a special setting, it will be consistent with nls_instance_parameters.
The client's character set requires consistency with the server to correctly display non-ASCII characters for the database.
If multiple settings exist, NLS priority level: SQL function > Alter SESSION > Environment variable or Registry > parameter file > database default parameters
Character set requirements are consistent, but language settings can be different, language settings are recommended in English. If the character set is ZHS16GBK, then Nls_lang can be AMERICAN_AMERICA.ZHS16GBK.

Involves a three-part character set,
1. Oracel server-side character set;
2. The character set of the Oracle client side;
3. The character set of the DMP file.
When doing data import, these three character sets are required to be imported in a correct way.

2.1 Querying the character set of the Oracle server side
There are many ways to identify the Oracle server-side character set, and the more intuitive query method is the following:
Sql> Select Userenv (' language ') from dual;
USERENV (' LANGUAGE ')
----------------------------------------------------
Simplified Chinese_china. Zhs16gbk

Sql> Select Userenv (' language ') from dual;
AMERICAN _ AMERICA. Zhs16gbk

2.2 How to query the character set of a DMP file
The DMP file exported with the Oracle Exp tool also contains character set information, and the 2nd and 3rd bytes of the DMP file record the character set of the DMP file. If the DMP file is small, such as only a few m or dozens of m, you can open it with UltraEdit (16 binary), look at the 2nd 3rd byte of content, such as 0354, and then use the following SQL to isolate its corresponding character set:
Sql> Select Nls_charset_name (To_number (' 0354 ', ' xxxx ')) from dual;
Zhs16gbk
If the DMP file is large, such as more than 2G (which is also the most common case), with a text editor opened very slowly or completely open, you can use the following command (on the UNIX host):
Cat Exp.dmp |od-x|head-1|awk ' {print $ |cut-c} ' 3-6
The corresponding character set can then be obtained using the SQL above.

2.3 Querying the character set of the Oracle client side
Under the Windows platform, it is the Nls_lang of the corresponding oraclehome in the registry. You can also set it in the DOS window itself,
For example: Set Nls_lang=american_america. Zhs16gbk
This will only affect the environment variables in this window.
Under the UNIX platform, it is the environment variable Nls_lang.
$echo $NLS _lang
American_america. Zhs16gbk

If the result of the check finds that the server side is inconsistent with the client-side character set, uniformly modify the same character set as the server side.

Oracle Character Set

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.