欢迎投稿

今日深度:

数据库中文乱码ORACLENLS_LANGLINUXLANG

数据库中文乱码ORACLENLS_LANGLINUXLANG


要维护数据库时候 经常使用LINUX系统和远程SHELL客户端连接到ORACLE数据库. 使用上面的SQLPLUS LSNRCTL RMAN工具
 
经常检查TRC文件,ORA文件 等. 要是出现乱码就糟糕了.
 
因为 你来之前别人已经装好了ORACLE 并且设置了中文.....
 
以前习惯了英文... 所以被中文撞了腰.
 
终端使用的 PUTTY SSH SECUTP XMAGRE等
 
这里涉及到系统 和数据库 两块东. 不要搞乱自己哦
 
EXPORT LANG ==> 是定义系统语言的
 
EXPORT NLS_LANG==> 定义数据库语言的
 
这些 我一般放在/home/oracle/.bash_profile 其他人喜欢放在/home/oracle/.bashrc里
 
设置之前了解下系统目前语言和支持的语言.
 
先讲 系统的LANG
cat /etc/sysconfig/i18n 系统默认语言
 
/usr/share/i18n/SUPPORTED  包含系统支持的本地语言
 
/usr/local/share/i18n/SUPPORTED  添加自定义的本地语言到这个文件
我的LINUX系统默认是英文 附加了中文支持
因此我的ORACLE用户下的环境变量 LANG=zh_CN.UTF-8
这样 保存 然后source /home/oracle/.bash_profile 生效下
df -h  中文标题出来了.
语言(Language), 地域 (Territory) 和字符集(Codeset)。一个locale的书写格式为: 语言[_地域[.字符集]].
注意是 小写 下划线 大写 点 大写
其他写法默认无效,不提示错误,让你转圈圈去
然后接着讲下数据库的NLS_LANG
哈哈 就是前面多了个NLS_
我的数据库默认装的英文 外挂下中文.
所以了先看下数据库的设置
select * from v$NLS_parameters
看主要的NLS_LANGUAGE ; NLS_TERRITORY;NLS_CHARACTERSET
我的上面分别是  AMERICAN;AMERICA;AL32UTF8
export NLS_LANG="SIMPLIFIED CHINESE_CHINA.AL32UTF8"
注意狗屎的细节 我们中国没有统一,所以有简体和繁体 .瞧上面 有空格是不? 就是因为这个台湾海峡在,就得上双引号.其他的语言类别就不用""...
另外注意点狗屎问题.ORACLE数据库的字符集 UTF8  不是UTF-8   注意干字.
系统变量有干 数据库则没有.
来点官方资料 充点门面. 狗屎的华为一天打三次电话 叫我去面试. 两个月累积下来有20次电话. 爷是专科生好不好啊 别这样玩我.知道你华为要E英文SB级.
Setting the NLS_LANG Environment Variable for Oracle Databases
 
Follow this procedure to set the NLS_LANG environment variable for Oracle databases.
To set the NLS_LANG environment variable for Oracle databases
 
Determine the NLS_LANG value.
In the data warehouse database, run the command
SELECT * FROM V$NLS_PARAMETERS
 
Make a note of the NLS_LANG value, which is in the format [NLS_LANGUAGE]_[NLS_TERRITORY].[NLS_CHARACTERSET].
For example: American_America.UTF8
 
For Windows:
Navigate to Control Panel > System and click the Advanced tab. Click Environment Variables.
In System variables section, click New.
In the Variable Name field, enter NLS_LANG.
In the Variable Value field, enter the NLS_LANG value that was returned in Step 1.
The format for the NLS_LANG value should be [NLS_LANGUAGE]_[NLS_TERRITORY].[NLS_CHARACTERSET].
 
For example: American_America.UTF8.
 
For UNIX, set the variable as shown below:
setenv NLS_LANG <NLS_LANG>
 
For example: setenv NLS_LANG American_America.UTF8.
 
If your data is 7-bit or 8-bit ASCII and the Informatica Server is running on UNIX, then set
 
NLS_LANG <NLS_LANGUAGE>_<NLS_TERRITORY>.WE8ISO8859P1
 
CAUTION: Make sure you set the NLS_LANG variable correctly, as stated in this procedure, or your data will not display correctly.
 
Reboot the machine after creating the variable.
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 
 
where:
 
Parameter Description
LANGUAGE Specifies the language and conventions for displaying messages, day name, and month name.
TERRITORY Specifies the territory and conventions for calculating week and day numbers.
CHARACTER_SET Controls the character set used for displaying messages.
C.2 Commonly Used Values for NLS_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
Chinese (PRC) SIMPLIFIED CHINESE_CHINA.ZHS16GBK
Chinese (Taiwan) TRADITIONAL CHINESE_TAIWAN.ZHT16MSWIN950
English (United Kingdom) ENGLISH_UNITED KINGDOM.WE8MSWIN1252
English (United States) AMERICAN_AMERICA.WE8MSWIN1252
French (Canada) CANADIAN FRENCH_CANADA.WE8MSWIN1252
French (France) FRENCH_FRANCE.WE8MSWIN1252
German (Germany) GERMAN_GERMANY.WE8MSWIN1252
Japanese JAPANESE_JAPAN.JA16SJIS
Korean KOREAN_KOREA.KO16MSWIN949
Russian RUSSIAN_CIS.CL8MSWIN1251

 

www.htsjk.Com true http://www.htsjk.com/oracle/22471.html NewsArticle 数据库中文乱码ORACLENLS_LANGLINUXLANG 要维护数据库时候 经常使用LINUX系统和远程SHELL客户端连接到ORACLE数据库. 使用上面的SQLPLUS LSNRCTL RMAN工具 经常检查TRC文件,ORA文件 等. 要是出现乱码就...
评论暂时关闭