记录湖北云计算中心日常工作关于系统运维,虚拟化云计算,数据库,网络安全等各方面问题。

详解Oracle中NLS_LANG变量的使用

目录结构:

contents structure [+]

1,关于NLS_LANG参数

Oracle provides Globalization Support that enables users to interact with a database in their own language, as defined by the NLS_LANG parameter. When you install Oracle Database Client components, Oracle Universal Installer sets the NLS_LANG parameter in the registry.

The locale setting of your operating system determines the value of the NLS_LANG parameter at installation. Table C-1 lists the operating system locale and NLS_LANG value mappings.

The NLS_LANG parameter is stored in the registry under the HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\HOMEID\NLS_LANG subkey, where ID is the unique number identifying the Oracle home.

The NLS_LANG parameter uses the following format:

NLS_LANG = LANGUAGE_TERRITORY.CHARACTER_SET 
复制代码
Oracle提供全球化的支持,通过定义NLS_LANG参数能够让用户用他们自己的语言使用数据库。当安装Oracle数据库客户端的时候,安装程序通常会在注册表中设置NLS_LANG参数。
在安装中,操作系统的区域设置会决定NLS_LANG参数的值。表C-1列出了操作系统区域和NLS_LANG的对照表。
NLS_LANG参数被存储在注册表中的HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\HOMEID\NLS_LANG子项下,其中ID是识别Oracle home的唯一数字。
NLS_LANG参数使用如下的格式:
NLS_LANG = LANGUAGE_TERRITORY.CHARACTER_SET 
复制代码

where:

Parameter Description
LANGUAGESpecifies the language and conventions for displaying messages, day name, and month name.
TERRITORYSpecifies the territory and conventions for calculating week and day numbers.
CHARACTER_SETControls the character set used for displaying messages.

 

2 NSL_LANG常用的值

Table C-1 lists commonly used NLS_LANG values for various operating system locales:

Table C-1 NLS_LANG Parameter Values

Operating System Locale NLS_LANG Value
Arabic (U.A.E.)ARABIC_UNITED ARAB EMIRATES.AR8MSWIN1256
BulgarianBULGARIAN_BULGARIA.CL8MSWIN1251
CatalanCATALAN_CATALONIA.WE8MSWIN1252
Chinese (PRC)SIMPLIFIED CHINESE_CHINA.ZHS16GBK
Chinese (Taiwan)TRADITIONAL CHINESE_TAIWAN.ZHT16MSWIN950
CroatianCROATIAN_CROATIA.EE8MSWIN1250
CzechCZECH_CZECH REPUBLIC.EE8MSWIN1250
DanishDANISH_DENMARK.WE8MSWIN1252
Dutch (Netherlands)DUTCH_THE NETHERLANDS.WE8MSWIN1252
English (United Kingdom)ENGLISH_UNITED KINGDOM.WE8MSWIN1252
English (United States)AMERICAN_AMERICA.WE8MSWIN1252
EstonianESTONIAN_ESTONIA.BLT8MSWIN1257
FinnishFINNISH_FINLAND.WE8MSWIN1252
French (Canada)CANADIAN FRENCH_CANADA.WE8MSWIN1252
French (France)FRENCH_FRANCE.WE8MSWIN1252
German (Germany)GERMAN_GERMANY.WE8MSWIN1252
GreekGREEK_GREECE.EL8MSWIN1253
HebrewHEBREW_ISRAEL.IW8MSWIN1255
HungarianHUNGARIAN_HUNGARY.EE8MSWIN1250
IcelandicICELANDIC_ICELAND.WE8MSWIN1252
IndonesianINDONESIAN_INDONESIA.WE8MSWIN1252
Italian (Italy)ITALIAN_ITALY.WE8MSWIN1252
JapaneseJAPANESE_JAPAN.JA16SJIS
KoreanKOREAN_KOREA.KO16MSWIN949
LatvianLATVIAN_LATVIA.BLT8MSWIN1257
LithuanianLITHUANIAN_LITHUANIA.BLT8MSWIN1257
NorwegianNORWEGIAN_NORWAY.WE8MSWIN1252
PolishPOLISH_POLAND.EE8MSWIN1250
Portuguese (Brazil)BRAZILIAN PORTUGUESE_BRAZIL.WE8MSWIN1252
Portuguese (Portugal)PORTUGUESE_PORTUGAL.WE8MSWIN1252
RomanianROMANIAN_ROMANIA.EE8MSWIN1250
RussianRUSSIAN_CIS.CL8MSWIN1251
SlovakSLOVAK_SLOVAKIA.EE8MSWIN1250
Spanish (Spain)SPANISH_SPAIN.WE8MSWIN1252
SwedishSWEDISH_SWEDEN.WE8MSWIN1252
ThaiTHAI_THAILAND.TH8TISASCII
Spanish (Mexico)MEXICAN SPANISH_MEXICO.WE8MSWIN1252
Spanish (Venezuela)LATIN AMERICAN SPANISH_VENEZUELA.WE8MSWIN1252
TurkishTURKISH_TURKEY.TR8MSWIN1254
UkrainianUKRAINIAN_UKRAINE.CL8MSWIN1251
VietnameseVIETNAMESE_VIETNAM.VN8MSWIN1258

3 在MS-DOS模式和Batch模式中设置NLS_LANG

Before you can use Oracle utilities such as SQL*Plus, SQL Loader, Import, and Export in MS-DOS mode, make sure that you have set the character set field of the NLS_LANG parameter for the session to the correct value.

This is required because MS-DOS mode uses, with a few exceptions, a different character set (or code-page) from Windows (ANSI code-page), and the default Oracle home NLS_LANG parameter in the registry is always set to the appropriate Windows code-page. If you do not set the NLS_LANG parameter for the MS-DOS mode session correctly, incorrect character conversion can corrupt error messages and data.

For Japanese, Korean, Simplified Chinese, and Traditional Chinese, the MS-DOS code-page is identical to the ANSI code-page. In this case, you do not need to set the NLS_LANG parameter in MS-DOS mode.

Similarly, in batch mode, set the correct character set value of NLS_LANG by inserting a SET NLS_LANG command at the start of the batch procedure, according to the character set of the files to be processed in the procedure.

复制代码
在你使用Oracle应用之前,比如在MS-DOS模式中使用SQL*Plus,SQL Loader,Import,和Export,确保你已经在本次会话中正确的设置了字符集属性和NLS_LANG参数属性。

这是必须的,因为MS-DOS模式的使用会带有一些的来着Windows(ANSI code-page)的不同字符集设置的异常,在注册表中默认的Oracle home NLS_LANG参数总是会被设置成适合Windows code-page的值。
如果你在MS-DOS模式中不正确的设置NLS_LANG参数的值,那么错误的字符转换将会损坏信息和数据。

对于日文,韩文,简体中文和繁体中文,MS—DOS code-page 和ANSI code-page的值一样。在这种情况下,你不需要在MS-DOS模式中设置NLS_LANG参数的值。

同样的,在Batch模式中,根据程序运行过程中被处理的文件字符,通过插入SET LANG_LANG 命令设置正确的NLS_LANG值。
复制代码

Table C-2 lists the Oracle character sets that correspond to the MS-DOS mode for various operating system locales:

Table C-2 Oracle Character Sets for Operating System Locales

Operating System Locale Character Set
CatalanWE8PC850
Chinese (PRC)ZHS16GBK
Chinese (Taiwan)ZHT16MSWIN950
CzechEE8PC852
DanishWE8PC850
DutchWE8PC850
English (United Kingdom)WE8PC850
English (United States)US8PC437
FinnishWE8PC850
FrenchWE8PC850
GermanWE8PC850
GreekEL8PC737
HungarianEE8PC852
ItalianWE8PC850
JapaneseJA16SJIS
KoreanKO16MSWIN949
NorwegianWE8PC850
PolishEE8PC852
PortugueseWE8PC850
RomanianEE8PC852
RussianRU8PC866
SlovakEE8PC852
SlovenianEE8PC852
SpanishWE8PC850
SwedishWE8PC850
TurkishTR8PC857
CatalanWE8PC850

4,注册表中NLS_LANG和系统环境变量中的NLS_LANG

当用户安装好Oracle客户端后会在注册表中出现NLS_LANG的注册信息,在操作系统的环境变量中用户也可以设置自己的NLS_LANG的值。

但是需要注意:

注册表中的NLS_LANG是用于对应Oracle数据库与windows 的code-page值的,这个值是在安装的过程中自动添加的,一般不要去修改,如果修改后NLS_LANG的值与code-page的值不对应的话,会出现不同字符的异常。

系统环境变脸中NLS_LANG是用于对应Oracle数据显示的,这个值在安装完成后可能会有,也可能没有,是可以修改的,如果希望以中文显示则修改为 NLS_LANG=SIMPLIFIED CHINESE_CHINA.ZHS16GBK ,也可以是英文的 NLS_LANG=AMERICAN_AMERICA.UTF8 ,建议在使用Oracle数据库之间将这里的NLS_LANG设置为英文显示。

5,参考文章

C  Oracle Database Client Globalization Support


分享到0

转载请标明出处【详解Oracle中NLS_LANG变量的使用】。

《www.92cto.com》 虚拟化云计算,系统运维,安全技术服务.

名字:

个人主页地址:

E-mail:

评论列表