关于Oracle客户端显示乱码问题

 看下面演示与分析:

SQL> select * from nls_database_parameters;
 
PARAMETER                      VALUE
------------------------------ ------------------------------
NLS_LANGUAGE                   AMERICAN
NLS_TERRITORY                  AMERICA
NLS_CURRENCY                   $
NLS_ISO_CURRENCY               AMERICA
NLS_NUMERIC_CHARACTERS         .,
NLS_CHARACTERSET               AL32UTF8
NLS_CALENDAR                   GREGORIAN
NLS_DATE_FORMAT                DD-MON-RR
NLS_DATE_LANGUAGE              AMERICAN
NLS_SORT                       BINARY
NLS_TIME_FORMAT                HH.MI.SSXFF AM
 
PARAMETER                      VALUE
------------------------------ ------------------------------
NLS_TIMESTAMP_FORMAT           DD-MON-RR HH.MI.SSXFF AM
NLS_TIME_TZ_FORMAT             HH.MI.SSXFF AM TZR
NLS_TIMESTAMP_TZ_FORMAT        DD-MON-RR HH.MI.SSXFF AM TZR
NLS_DUAL_CURRENCY              $
NLS_COMP                       BINARY
NLS_LENGTH_SEMANTICS           BYTE
NLS_NCHAR_CONV_EXCP            FALSE
NLS_NCHAR_CHARACTERSET         AL16UTF16
NLS_RDBMS_VERSION              9.2.0.4.0
 
20 rows selected.
 
windows 客户机上: 
H:\Users\LuoTaoyang>chcp
活动代码页: 936
 
H:\Users\LuoTaoyang>set NLS_LANG=American_America.ZHS16GBK
 
 
SQL> DESC chartest;
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 
 ID                                                 NUMBER(38)
 NAME                                               VARCHAR2(20)
 
SQL> insert into chartest values(1,'123 你好吗ABC');
1 row created.
SQL> SELECT * from chartest;
        ID NAME
---------- ----------------------------------------
         1 123
你好吗ABC
SQL> select id,dump(name,1016) from chartest;
        ID
----------
DUMP(NAME,1016)
--------------------------------------------------------------------------------
         1
Typ=1 Len=15 CharacterSet=AL32UTF8: 31,32,33,e4,bd,a0,e5,a5,bd,e5,90,97,41,42,43
#‘123 你好吗ABC’在ZHS16GBK字符集下16进制代码为:31 32 33 C4 E3 BA C3 C2 F0 41 42 43,之所以跟Oracle存储的不同时因为客户端字符集(ZHS16GBK)与Oracle主字符集(AL32UTF8)不同,Oracle在底层发生字符集转换的原因。
 
 
H:\Users\LuoTaoyang>set NLS_LANG=American_America.AL32UTF8
 
 
SQL> select * from chartest;
 
        ID NAME
---------- --------------------
         1 123 浣�濂藉��ABC
 
# 出现乱码是因为此时Oracle客户端字符集与Oracle主字符集相同,Oracle不发生字符集转换。但在windows下依然用字符集(ZHS16GBK)显示。

你可能感兴趣的:(oracle,职场,乱码,客户端,休闲)