CentOS Linux远程Oracle解决中文乱码问题

准备导数据了,可是试了一下,在服务器上加一条中文条目,客户端显示乱码,老扎心了,来自https://www.hsli.top

有下列几个地方需要设置得一致

1
SQL> select userenv('language') from dual;

Oracle用户目录下的.bash_profile里面有一行

1
export NLS_LANG=`AMERICAN_AMERICA.ZHS16GBK`

没有的话自己加上

本地Oracle client的注册表项regedit ->HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ORACLE\KEY_OraClient12Home1_32bit->NLS_LANG

以及本地环境变量NLS_LANG

别的都好该,唯独第一个地方最不好改了,下面的方法来改:

1
2
3
4
5
6
7
8
9
10
11
12
13
SQL> shutdown immediate

SQL> startup mount

SQL> alter system enable restricted session;

SQL> alter system set job_queue_processes=0;

SQL> alter system set aq_tm_processes=0;

SQL> alter database open;

SQL> alter database character set zhs16gbk;

这里会报错,不用管

1
SQL> alter database character set internal_use zhs16gbk;

查看一下搞成了没

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
SQL> set linesize 200;
SQL> set pagesize 20;
SQL> select * from v$nls_parameters;

PARAMETER VALUE
---------------------------------------------------------------- ----------------------------------------------------------------
NLS_LANGUAGE AMERICAN
NLS_TERRITORY AMERICA
NLS_CURRENCY $
NLS_ISO_CURRENCY AMERICA
NLS_NUMERIC_CHARACTERS .,
NLS_CALENDAR GREGORIAN
NLS_DATE_FORMAT DD-MON-RR
NLS_DATE_LANGUAGE AMERICAN
NLS_CHARACTERSET `ZHS16GBK`
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_NCHAR_CHARACTERSET AL16UTF16
NLS_COMP BINARY

PARAMETER VALUE
---------------------------------------------------------------- ----------------------------------------------------------------
NLS_LENGTH_SEMANTICS BYTE
NLS_NCHAR_CONV_EXCP FALSE

19 rows selected.

干成了

mark

如果文章有用,请随意打赏