时间:2021-07-01 10:21:17 帮助过:50人阅读
我装完Oracle 11g rac,登录sqlplus时出现了???乱码,如下:[oracle@db ~]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.1.0 P
我装完Oracle 11g rac,登录sqlplus时出现了???乱码,如下:
[oracle@db ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Thu Dec 20 13:40:46 2012
Copyright (c) 1982, 2009, Oracle. All rights reserved.
???:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> exit
? Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options ??
这个问题我以前遇到过,但现在却一时不知道如何解决了。
这其实是一个非常初级的问题,原因在于我尽量精简rac安装过程,oracle用户的环境变量能少则少。解决这个问题很简单,在oracle用户的环境变量中添加库所用的字符集就可以了,如下:
[oracle@db ~]$ vi .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
export ORACLE_BASE=/u01/oracle
export ORACLE_HOME=$ORACLE_BASE/db
export ORACLE_SID=orcl
export PATH=$PATH:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export NLS_LANG=AMERICAN_AMERICA.UTF8
#export NLS_LANG=AMERICAN_AMERICA.UTF8 是新添加的内容,这里我的库用的UTF8字符集。
保存后,重启加载环境变量:
[oracle@db ~]$ source .bash_profile
再次登录sqlplus,已经没有???乱码了:
[oracle@db ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Thu Dec 20 13:51:33 2012
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
如果不知道自己库用的什么字符集或没记清楚,可以用以下sql查出:
SQL> select value from v$nls_parameters where parameter='NLS_LANGUAGE';
VALUE
----------------------------------------------------------------
AMERICAN
SQL> select value from v$nls_parameters where parameter='NLS_TERRITORY';
VALUE
----------------------------------------------------------------
AMERICA
SQL> select value from v$nls_parameters where parameter='NLS_CHARACTERSET';
VALUE
----------------------------------------------------------------
UTF8
另外,有人查出来的是中文字符集,如SIMPLIFIED CHINESE, CHINA ,,ZHS16GBK,
可以试试:NLS_LANG='SIMPLIFIED CHINESE_CHINA.ZHS16GBK' 或NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK"