看下面演示与分析
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 ALUTF
NLS_CALENDAR GREGORIAN
NLS_DATE_FORMAT DDMONRR
NLS_DATE_LANGUAGE AMERICAN
NLS_SORT BINARY
NLS_TIME_FORMAT HHMISSXFF AM
PARAMETER VALUE
NLS_TIMESTAMP_FORMAT DDMONRR HHMISSXFF AM
NLS_TIME_TZ_FORMAT HHMISSXFF AM TZR
NLS_TIMESTAMP_TZ_FORMAT DDMONRR HHMISSXFF AM TZR
NLS_DUAL_CURRENCY $
NLS_COMP BINARY
NLS_LENGTH_SEMANTICS BYTE
NLS_NCHAR_CONV_EXCP FALSE
NLS_NCHAR_CHARACTERSET ALUTF
NLS_RDBMS_VERSION
rows selected
windows客户机上
H:\Users\LuoTaoyang>chcp
活动代码页:
H:\Users\LuoTaoyang>set NLS_LANG=American_AmericaZHSGBK
SQL> DESC chartest;
Name Null? Type
ID NUMBER()
NAME VARCHAR()
SQL> insert into chartest values(你好吗ABC);
row created
SQL> SELECT * from chartest;
ID NAME
你好吗ABC
SQL> select iddump(name) from chartest;
ID
DUMP(NAME)
Typ= Len= CharacterSet=ALUTF: ebdaeabde
#你好吗ABC在ZHSGBK字符集下进制代码为 C E BA C C F 之所以跟Oracle存储的不同时因为客户端字符集(ZHSGBK)与Oracle主字符集(ALUTF)不同Oracle在底层发生字符集转换的原因
H:\Users\LuoTaoyang>set NLS_LANG=American_AmericaALUTF
SQL> select * from chartest;
ID NAME
浣犲ソ钖桝BC
#出现乱码是因为此时Oracle客户端字符集与Oracle主字符集相同Oracle不发生字符集转换但在windows下依然用字符集(ZHSGBK)显示