Oracle 字符集错误情况处理简单方法


情况一:
[Oracle@ www.bkjia.com ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Tue Jun 26 20:52:47 2012
Copyright (c) 1982, 2009, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01157: ????/?????? 4 - ??? DBWR ????
ORA-01110: ???? 4: '+DGASM/ora11/datafile/users.261.785186921'

SQL> exit
英语显示?????
情况二、数据库中查询时,汉字显示乱码
如果出现上面两种情况,那么先到数据库中查询数据库的字符集
SQL> select * from nls_database_parameters where parameter in ('NLS_CHARACTERSET','NLS_NCHAR_CHARACTERSET');
PARAMETER            VALUE
-------------------- --------------------------------------------------
NLS_CHARACTERSET     ZHS16GBK
NLS_NCHAR_CHARACTERS AL16UTF16
ET
可以看到,当前数据库的字符集为ZHS16GBK, 国家字符集为AL16UTF16;
然后修改用户环境变量中的定义的字符集和数据库字符集保持一致
在 .bash_profile 中加入下面的变量即可
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK

相关内容