设置环境变量 重启PLSQL
NLS_LANG=AMERICAN_AMERICA.AL32UTF8
原因:
客户端与服务器端编码不一致
了解下NLS_LANG的知识
NLS_LANG 参数组成
NLS_LANG=<Language>_<Territory>.<Clients Characterset>
查看oracle服务端编码:select * from sys.nls_database_parameters;
从下面服务端 编码我们可以得到: NLS_LANG = AMERICAN_AMERICA.AL32UTF8
查看oracle服务端编码:select * from sys.nls_database_parameters;
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
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 11.2.0.1.0
查看client编码 :select * from sys.nls_session_parameters;
NLS_LANGUAGE SIMPLIFIED CHINESE
NLS_TERRITORY CHINA
NLS_CURRENCY ¥
NLS_ISO_CURRENCY CHINA
NLS_NUMERIC_CHARACTERS .,
NLS_CALENDAR GREGORIAN
NLS_DATE_FORMAT DD-MON-RR
NLS_DATE_LANGUAGE SIMPLIFIED CHINESE
NLS_SORT BINARY
NLS_TIME_FORMAT HH.MI.SSXFF AM
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
明显客户端的编码和服务器端 的不一致!!!!解决办法:
设置环境变量 重启PLSQL
NLS_LANG=AMERICAN_AMERICA.AL32UTF8
此方法也适合用exp imp !以免中文有乱码出现!或部分数据乱码!
WINNT> set NLS_LANG=AMERICAN_AMERICA.AL32UTF8
LINUX> export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
查看 NLS_LANG 的方法
Windows使用:echo %NLS_LANG%
C:\Users\Administrator>echo %NLS_LANG%
AMERICAN_AMERICA.AL32UTF8
修改db编码的办法:(在oracle 11g上通过测试) --风险操作....最好不要用!!!!!!!!
SQL> conn system as sysdba;
SQL> shutdown immediate;
SQL> startup mount;
SQL> alter system enable restricted session;
SQL> alter system set job_queue_processes=0;
SQL> alter database open;
SQL> alter database character set internal_use AL32UTF8;
SQL> shutdown immediate;
SQL> startup
另外如果PLSQL查看结果乱码 可能是字体的问题 :请见
http://blog.csdn.net/qq378527566/article/details/7816768