Oracle 8i | Oracle 9i | Oracle 10g | Oracle 11g | Oracle 12c | Miscellaneous | PL/SQL | SQL | Oracle RAC | Oracle Apps | Linux

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.

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;

For more information see:

Hope this helps. Regards Tim...

Back to the Top.