手机版
你好,游客 登录 注册
背景:
阅读新闻

sqlplus中???乱码问题的解决

[日期:2013-06-12] 来源:Linux社区  作者:verrion [字体:大 中 小]

我装完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"

更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12

linux
相关资讯       sqlplus  sqlplus乱码 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款