Oracle字符集


在Oracle数据库字符集和本地字符集相同的时候,通常不会出现乱码,但是如果两个字符集不同呢?就会涉及到字符集转换的问题了。最近的项目需要在日文环境和中文环境来回切换,记录下Oracle字符集相关的一些SQL和命令,仅作备忘。

查看Oracle数据库字符集

select * from nls_database_parameters
PARAMETER                      VALUE
—————————— ——————————————————————————–
NLS_LANGUAGE                   AMERICAN
NLS_TERRITORY                  AMERICA
NLS_CURRENCY                   $
NLS_ISO_CURRENCY               AMERICA
NLS_NUMERIC_CHARACTERS         .,
NLS_CHARACTERSET               ZHS16GBK

查看会话字符集

select * from nls_session_parameters
PARAMETER                                                    VALUE
———————————————————— ——————————————————————————–
NLS_LANGUAGE                                                 SIMPLIFIED CHINESE
NLS_TERRITORY                                                CHINA
NLS_CURRENCY                                                 」、
NLS_ISO_CURRENCY                                             CHINA
NLS_NUMERIC_CHARACTERS                                       .,

Windows命令行查看命令字符编码

>chcp
現在のコード ページ: 932

Linux终端查看命令字符编码

$ locale

Windows下修改Oracle会话使用的字符编码集

set NLS_LANG=AMERICAN_AMERICA.ZHS16GBK

Linux下修改Oracle会话使用的字符编码集

$ export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK

sqlplus中修改会话字符集

alter session set NLS_LANGUAGE=‘AMERICAN’

关于NLS_LANG参数的含义:

NLS_LANG包含三个部分,语言_地区.字符集,就是上面查询出来的NLS_LANGUAGE,NLS_TERRITORY,NLS_CHARACTERSET

Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s