sqlplus中???亂碼問題的解決

來源:互聯網
上載者:User

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

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.