SQL> connect / as sysdba; ---dba用户连接数据库
SQL> select name,value$ from props$ where name like '%NLS%';---语句查询当前数据库服务器字符集
NAME
------------------------------------------------------------
VALUE$
--------------------------------------------------------------------------------
NLS_LANGUAGE
AMERICAN
NLS_TERRITORY
AMERICA
NLS_CURRENCY
$
NAME
------------------------------------------------------------
VALUE$
--------------------------------------------------------------------------------
NLS_ISO_CURRENCY
AMERICA
NLS_NUMERIC_CHARACTERS
.,
NLS_CHARACTERSET ----找到查出来的结果中的该项参数
下面是修改过程:
SQL> shutdown immediate; ---停止数据库
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount ---启动数据库到mount状态
ORACLE instance started.
Total System Global Area 235999352 bytes
Fixed Size 450680 bytes
Variable Size 201326592 bytes
Database Buffers 33554432 bytes
Redo Buffers 667648 bytes
Database mounted.
---下面是修改过程,按步骤修改
SQL> alter session set sql_trace=true;
Session altered.
SQL> alter system enable restricted session;
System altered.
SQL> alter system set job_queue_processes=0;
System altered.
SQL> alter system set aq_tm_processes=0;
System altered.
SQL> alter database open;
Database altered.
SQL> set linesize 120;
SQL> alter database character set zhs16gbk;
alter database character set zhs16gbk
*
ERROR at line 1:
ORA-12712: new character set must be a superset of old character set
SQL> ALTER DATABASE character set INTERNAL_USE zhs16gbk;
# 使用INTERNAL_USE可以跳过超集的检查,
(ALTER DATABASE character set INTERNAL_USE )
Database altered.
SQL> shutdown immediate; ---再停止数据库
Database closed.
Database dismounted.
ORACLE instance shut down.
---启动数据库
SQL> STARTUP
ORACLE instance started.
Total System Global Area 235999352 bytes
Fixed Size 450680 bytes
Variable Size 201326592 bytes
Database Buffers 33554432 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.
SQL>
----再次查看当前字符集
SQL> select name,value$ from props$ where name like '%NLS%';
NAME
------------------------------
VALUE$
--------------------------------------------------------------------------------
NLS_LANGUAGE
SIMPLIFIED CHINESE
NLS_TERRITORY
CHINA
NLS_CURRENCY
?
NAME
------------------------------
VALUE$
--------------------------------------------------------------------------------
NLS_ISO_CURRENCY
CHINA
NLS_NUMERIC_CHARACTERS
.,
NLS_CHARACTERSET
---【已经修改成为中文编码了】
今天的情况特殊,修改完了,中文乱码还是“靠”字,- -
后来试着修改系统字符集
在oracle下 .bash_profile 文件里面加入
export NLS_LANG="Simplified Chinese_CHINA.ZHS16GBK"
再次登录查看,还是不行
最后把NLS_LANG中后面的字符集修改成,查看结果,搞掂完成,回家!
总结:要系统字符集和数据库字符集相对应才会解决中文乱码问题,dbca建库时,也要注意字符集选择问题。