redhat使用问题总结三——改变oracle字符集

阅读更多
在安装oracle11发行版时,为选择字符集采用了默认字符集,安装完毕,将备份还原后发现中文乱码。后来通过select userenv('language') from dual查询数据库字符集发现不是utf8.
修改数据库字符集:
SQL> conn /as sysdba  
Connected.  
SQL> shutdown immediate;  
Database closed.  
Database dismounted.  
ORACLE instance shut down.  
SQL> startup mount  
ORACLE instance started.  
  
Total System Global Area  236000356 bytes  
Fixed Size                   451684 bytes  
Variable Size             201326592 bytes  
Database Buffers           33554432 bytes  
Redo Buffers                 667648 bytes  
Database mounted.  
SQL> ALTER SESSION SET SQL_TRACE=TRUE;//语句跟踪  
System altered.  
SQL> ALTER SYSTEM ENABLE RESTRICTED SESSION;  
  
System altered.  
  
SQL> ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;  
  
System altered.  
  
SQL> ALTER SYSTEM SET AQ_TM_PROCESSES=0;  
  
System altered.  
  
SQL> alter database open;  
   
Database altered.  
  
SQL> ALTER DATABASE CHARACTER SET AL32UTF8;  
ALTER DATABASE CHARACTER SET AL32UTF8  
*  
ERROR at line 1:  
ORA-12712: new character set must be a superset of old character set  
  
  
提示我们的字符集:新字符集必须为旧字符集的超集,这时我们可以跳过超集的检查做更改:  
  
SQL> ALTER DATABASE character set INTERNAL_USE AL32UTF8;  
  
Database altered.  

修改后发现中文还是乱码,后来发现原来地区和语言不是中国简体。
解决方式:
修改oracle环境变量
Vi .bash_profile
在其中加上
NLS_LANG="SIMPLIFIED CHINESE_CHINA".AL32UTF8
export NLS_LANG

然后使用. ./.bash_profile重新加载环境变量或者重启服务器。

你可能感兴趣的:(linux,oracle,字符集)