Character Set Migration using CSSCAN and CSALTER(更改字符集)

This article presents a simple example of migrating the default character set of a database using the CSSCAN and CSALTER character set scanner utilities provided by Oracle. The basic steps involved in character set conversion are listed below.

  • Backup
  • CLUSTER_DATABASE=FALSE (*RAC Only*)
  • SHUTDOWN IMMEDIATE
  • STARTUP
  • CSSCAN
  • SHUTDOWN IMMEDIATE
  • STARTUP RESTRICT
  • CSALTER
  • CLUSTER_DATABASE=TRUE (*RAC Only*)
  • SHUTDOWN IMMEDIATE
  • STARTUP

Performing a backup before starting the character set conversion is very important. If the conversion fails part way through, you must restore from a backup before re-attempting the conversion.

With the backup complete, the instance must be restarted. In the case of RAC databases, the CLUSTER_DATABASE parameter should be set to FALSE, then all RAC instances stoped and only one restarted.

ALTER SYSTEM SET CLUSTER_DATABASE=FALSE SCOPE=SPFILE; -- RAC Only
SHUTDOWN IMMEDIATE;
STARTUP;

Once the database is open, the CSSCAN utility is run. This example command below would perform a scan of the whole database.

CSSCAN \"sys/password@db10g AS SYSDBA\" FULL=Y

If the character set migration utility schema is not installed on your database, you will get the following error.

C:\>CSSCAN \"sys/password@db10g AS SYSDBA\" FULL=Y

Character Set Scanner v2.1 : Release 10.2.0.0.0 - Production on Tue Dec 5 06:54:23 2006

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
CSS-00107: Character set migration utility schema not installed

Scanner terminated unsuccessfully.

C:\>

The character set migration utility schema is installed by running the "$ORACLE_HOME/rdbms/admin/csminst.sql" script in SQL*Plus as the SYS user. Once the schema is present, the character set scanner should work normally.

In the following example, the current database character set is "WE8MSWIN1252", which we will convert to "WE8ISO8859P15" using 32 scan processes.

C:\>CSSCAN \"sys/password@db10g AS SYSDBA\" FULL=Y

Character Set Scanner v2.1 : Release 10.2.0.0.0 - Production on Tue Dec 5 07:00:36 2006

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

Current database character set is WE8MSWIN1252.

Enter new database character set name: > WE8ISO8859P15

Enter array fetch buffer size: 1024000 >

Enter number of scan processes to utilize(1..32): 1 > 32

Enumerating tables to scan...

. process 1 scanning SYS.SOURCE$[AAAABIAABAAAAIRAAA]
. process 2 scanning SYS.SOURCE$[AAAABIAABAAAHCJAAA]
.
.
. process 14 scanning SYS.WRH$_SERVICE_WAIT_CLASS[AAANZRAADAAAJKBAAA]
. process 22 scanning SYS.WRH$_WAITSTAT[AAANUxAADAAAHzJAAA]

Creating Database Scan Summary Report...

Creating Individual Exception Report...

Scanner terminated successfully.

C:\>

Once the scan has completed successfully, the database should be opened in restricted mode so you can run the "$ORACLE_HOME/rdbms/admin/csalter.plb" script as the SYS user. The example below shows a successful conversion.

SQL> SHUTDOWN IMMEDIATE
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> STARTUP RESTRICT
ORACLE instance started.

Total System Global Area  289406976 bytes
Fixed Size                  1248600 bytes
Variable Size              83886760 bytes
Database Buffers          201326592 bytes
Redo Buffers                2945024 bytes
Database mounted.
Database opened.
SQL> @@csalter.plb

0 rows created.


Function created.


Function created.


Procedure created.

This script will update the content of the Oracle Data Dictionary.
Please ensure you have a full backup before initiating this procedure.
Would you like to proceed (Y/N)?Y
old   6:     if (UPPER('&conf') <> 'Y') then
new   6:     if (UPPER('Y') <> 'Y') then
Checking data validility...
begin converting system objects

PL/SQL procedure successfully completed.

Alter the database character set...
CSALTER operation completed, please restart database

PL/SQL procedure successfully completed.


0 rows deleted.


Function dropped.


Function dropped.


Procedure dropped.

SQL>

If there are possible conversion problems, the process will report the problem and clean itself up without performing the conversion. Here are a couple of the messages I got when trying this process.

# When I tried to convert WE8MSWIN1252 -> AL32UTF8.
Checking data validility...
Unrecognized convertible date found in scanner result

# When I tried to run the CSALTER script without a SHUTDOWN-STARTUP RESTRICT.
Checking data validility...
Sorry only one session is allowed to run this script
Once the conversion is complete, you must restart the instance. In the case of RAC databases, the  CLUSTER_DATABASE parameter should be set back to TRUE.
ALTER SYSTEM SET CLUSTER_DATABASE=TRUE SCOPE=SPFILE; -- RAC Only
SHUTDOWN IMMEDIATE;
STARTUP;
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值