Oracle的UTF8字符集由来已久,至少在8的时候就已经存在了,而对应的是UNICODE 3.0。而AL32UTF8字符集是9i才出现的,其对应的是UNICODE 5.0。这两种字符集的区别在于,UNICODE 5.0与3.0相比,又增加了一些新的补充字符。但是在实际当中,使用到这些新增字符的可能性非常小,因此绝大部分情况下,选择UTF8也是足够的。AL32UTF8字符集是9i才出现的,那么对于9i以后的版本访问没有任何问题,但是对于8i及以前的版本,则不认识这个字符集。这就使得8i及更低版本的客户端在访问9i以上AL32UTF8的数据库时,会碰到各种各样的问题。因此,如果数据库版本都在9i及其以上,不需要考虑ORACLE8的数据库,建议使用AL32UTF8字符集,它采用的Unicode标准要比UTF8采用的Unicode标准更新,支持的字符也更多一些。如果要考虑ORACLE8数据库,建议使用UTF8字符集,它的兼容性好,在ORACLE8及8I数据库上使用AL32UTF8字符集容易出现问题。随着现在版本11g逐渐开始称为主流版本,8i客户端的情况已经越来越少见了,因此在11.2的DBCA中,UTF8已经不是推荐字符集列表中的一员了。我们在遇到不兼容的问题时就要修改字符集。AL32UTF8-->UTF8修改字符集的步骤:
shutdown immediate; //关闭数据库服务器
startup mount;
alter session set sql_trace=true;
alter system enable restricted session;
alter system set job_queue_processes=0;
alter system set aq_tm_processes=0;
alter database open;
alter database character set internal_use utf8;
alter session set sql_trace=false;
shutdown immediate;
startup;
下面是别人的一个实例:
#su - oracle
$sqlplus "/ as sysdba"
SQL*Plus: Release11.2.0.3.0 Production on Wed Apr 18 14:40:10 2012
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
SQL>
修改之前的字符集
SQL> select * from v$nls_parameters where parameter='NLS_CHARACTERSET';
PARAMETER VALUE
----------------- ----------------------------
NLS_CHARACTERSET AL32UTF8
SQL>
开始修改
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 1603411968 bytes
FixedSize 2226912 bytes
VariableSize 402654496 bytes
Database Buffers 1191182336bytes
RedoBuffers 7348224 bytes
Database mounted.
SQL> alter session setsql_trace=true;
Session altered.
SQL> alter system enable restricted session;
System altered.
SQL> show parameter job_queue_process
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
job_queue_processes integer 1000
SQL> alter system setjob_queue_processes=0;
System altered.
SQL> show parameter aq_tm_processes
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
aq_tm_processes integer 0
SQL> alter databaseopen;
Database altered.
SQL> alter databasecharacter set internal_use utf8;
Database altered.
SQL> alter session setsql_trace=false;
Session altered.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 1603411968 bytes
FixedSize 2226912 bytes
VariableSize 402654496 bytes
Database Buffers 1191182336bytes
Redo Buffers 7348224 bytes
Database mounted.
Database opened.
SQL>
修改之后的字符集
SQL> select * from v$nls_parameters where parameter='NLS_CHARACTERSET';
PARAMETER VALUE
----------------- ----------------------------
NLS_CHARACTERSET UTF8
SQL>
--------end-------
有关oracle字符集的知识点可以参看下面两篇帖子:
http://blog.csdn.net/robinson_0612/article/details/6030398