问题描述:
数据库是Oracle10g,Version 10.2.0.1.0。操作系统的winXP。
数据库原始的字符集是ZHS16GBK,要转换成AL32UTF8。
操作流程:
以sysdba用户登录,用的命令如下:
shutdown immediate;
startup mount;
alter system enable restricted session;
show parameter processes;
-- 数据库中参数为set job_queue_processes,aq_tm_processes均为0
alter database open;
alter database character set INTERNAL_USE AL32UTF8;
数据库字符集转换成功后。
数据库中的部分数据出现乱码。如性别中的“女”大多数都变成了乱码。
执行如下sql语句:select t0.xm,t0.xb from table_0 t0 where t0.xb <> '男';
会出现如下结果: 张三,男
注:很清楚ZHS16GBK,AL32UTF8之间没有超集与子集的关系。
    将数据库字符集用上面的命令转换回ZHS16GBK后,数据显示查询均正常,无乱码现象。
问题:
1. 对于已经出现的乱码如何才能让其在AL32UTF8下显示正常?
2. 转换字符集的命令是否有问题。用什么命令才能避免出现乱码?

解决方案 »

  1.   

    数据库字符集不能修改的。
    The database (national) character set NLS_(NCHAR)_CHARACTERSET) is defined by the "Create Database" command.
    * The NLS_CHARACTERSET and NLS_NCHAR_CHARACTERSET parameters cannot be overridden by instance or session parameters.
    They are defined by the value specified in the "CREATE DATABASE command and are not intended to be changed afterwards dynamically. Do NOT update system tables to change the character set. This can corrupt your database and potentially make it impossible to open the database again.