登录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 ??
这是由于系统字符集和数据库的不一致导致的,可以通过修改系统的语言变量解决
[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"
转载于:https://blog.51cto.com/xu3jin/1310522