5、修改oracle的字符集
注意:修改字符集前需要将表空间进行数据泵备份;
5.1、修改server端字符集:
1、登录到oracle实例查看字符集:
[oracle@slave-node2 ~]$ echo $ORACLE_SID
orcl
[oracle@slave-node2 ~]$ sqlplus sys/123456@orcl as sysdba
SQL> show parameter name;
SQL> select userenv('language') from dual;
USERENV('LANGUAGE')
--------------------------------------------------------------------------------
AMERICAN_AMERICA.ZHS16GBK
2、修改字符集,依次执行如下命令:
SQL>SHUTDOWN IMMEDIATE;
SQL>STARTUP MOUNT;
SQL>ALTER SYSTEM ENABLE RESTRICTED SESSION;
SQL>ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;
SQL>ALTER SYSTEM SET AQ_TM_PROCESSES=0;
SQL>ALTER DATABASE OPEN;
SQL>ALTER DATABASE CHARACTER SET INTERNAL_USE AL32UTF8;
SQL>SHUTDOWN IMMEDIATE;
SQL>STARTUP;
SQL> select userenv('language') from dual;
USERENV('LANGUAGE')
----------------------------------------------------
AMERICAN_AMERICA.AL32UTF8
5.2、修改client端字符集:
1、设置client端字符集:
[oracle@slave-node2 ~]$ cat /home/oracle/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
export ORACLE_BASE=/application/oracle
#oracl安装目录
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
#oracle路径
export ORACLE_SID=orcl
#oracle启动数据库实例名
export ORACLE_TERM=xterm
#xterm窗口模式安装
export PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH
#添加系统环境变量
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
#添加系统环境变量
export LANG=en_US.UTF-8
#防止安装过程出现乱码
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
#设置Oracle客户端字符集,必须和oracle安装时的字符集保持一致
#将ZHS16GBK改为AL32UTF8,保存退出;
2、生效配置文件:
[oracle@slave-node2 ~]$ source /home/oracle/.bash_profile
5.3、说明:
以上是一个oracle实例的字符集修改,如果有多个oracle实例,需要进入到实例中按照"5.1"步骤执行即可;