Oracle 11g 软件显示中文乱码
环境说明
Red Hat Enterprise Linux Server release 6.10 (Santiago) 系统;
Oracle 11.2.0.4.0 版本搭建备库。
现象
Oracle 提示字乱码。
oracle@hostname:/home/oracle $sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Fri Mar 22 15:22:33 2024
Copyright (c) 1982, 2013, Oracle. All rights reserved.
???:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> set lines 200 pages 200
SQL> col name for a20
SQL> col db_unique_name for a20
SQL> select name,db_unique_name,open_mode,database_role,switchover_status from v$database;
select name,db_unique_name,open_mode,database_role,switchover_status from v$database
*
? 1 ?????:
ORA-01507: ??????
问题分析
操作系统安装的中文字体。
检查了终端显示字符,设置utf8\gb18030等字符都一样中文乱码,说明与终端工具无关。
再次检查操作系统支持字符也是支持中文的,最后检查oracle客户端显示字符,NLS_LANG值未设置。
解决办法
将环境变量设置:export NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK"后,可以正常显示中文字体。
oracle@hostname:/home/oracle $cat .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 PATH
export NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK"
export ORACLE_BASE=/oracle/app
export ORACLE_HOME=/oracle/app/product/11.2.0.4
export ORACLE_SID=test
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
export TNS_ADMIN=$ORACLE_HOME/network/admin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32:/lib/usr/lib:/usr/local/lib
alias s='sqlplus / as sysdba'
PS1='$LOGNAME@'hostname':$PWD $'; export PS1
NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'; export NLS_DATE_FORMAT
ORACLE_TERM=xterm; export ORACLE_TERM
set -o vi
if [ -t 0 ]; then
stty intr ^C
fi
umask 022
oracle@hostname:/home/oracle $source .bash_profile
oracle@hostname:/home/oracle $sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on 星期五 3月 22 15:25:17 2024
Copyright (c) 1982, 2013, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.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.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断开