Saturday 14 March 2015

Character set conversion for oracle database

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. 
Method 1:-( For first time);
Step 1: 
Before starting character set conversion we need the following pre-checking for database. 
1. Remove the invalid objects 
                               List all of schema which contains invalid objects. These invalid object need to be compiled or dropped, if they are unused 
SQL> select distinct owner from dba_objects where status=’INVALID’; 
SQL> exec utl_recomp.recomp_serial(‘SCHEMA’); 
2 . Purge the Recyclebin 
If there are object in recyclebin then purge the recyclebin otherwise during CSALTER you will get ora-38301. 
SQL> purge recyclebin;
SQL> purge dba_recyclebin;
3 . Take a full backup of the database. 
Performing a backup before starting the character set conversion is very important. If the conversion fails in middle you must restore from a backup before reattempting the conversion. 
Step 2:
            Install the CSS utility. If the character set migration utility schema is not installed on your database. You will get the error: CSS-00107: Character set migration utility schema not installed. Install the CSS utility by running the csminst.sql script from $ORACLE_HOME\rdbms\admin. 
SQL>@$ORACLE_HOME/rdbms/admin/csminst.sql
Step 3:(Optional) 
   Run the Database Character Set Scanner utility as set the oracle_sid and run as

$]CSSCAN sys/password@instance_name AS SYSDBA FULL=Y
Step 4: 
        Once the scan has completed successfully, the database should be opened in restricted mode so you can run the CSALTER script from $ORACLE_HOME\rdbms\admin folder. If there is any possible conversion problem, the process will report the problem and clean itself up without performing the conversion. Once the successfully conversion is completed you must restart the instance.
SQL>shutdown immediate;
SQL>startup restrict;
SQL> ALTER DATABASE CHARACTER SET INTERNAL_USE AL32UTF8;
SQL>shutdown immediate;
SQL>startup;
For second time:-
Step 1: 
Before starting character set conversion we need the following pre-checking for database. 
2. Remove the invalid objects 
                               List all of schema which contains invalid objects. These invalid object need to be compiled or dropped, if they are unused 
SQL> select distinct owner from dba_objects where status=’INVALID’; 
SQL> exec utl_recomp.recomp_serial(‘SCHEMA’); 
2 . Purge the Recyclebin 
If there are object in recyclebin then purge the recyclebin otherwise during CSALTER you will get ora-38301. 
SQL> purge recyclebin;
SQL> purge dba_recyclebin;
3 . Take a full backup of the database. 
Performing a backup before starting the character set conversion is very important. If the conversion fails in middle you must restore from a backup before reattempting the conversion. 
Step 2: 
        Once the scan has completed successfully, the database should be opened in restricted mode so you can run the CSALTER script from $ORACLE_HOME\rdbms\admin folder. If there is any possible conversion problem, the process will report the problem and clean itself up without performing the conversion. Once the successfully conversion is completed you must restart the instance.
SQL>shutdown immediate;
SQL>startup restrict;
SQL> ALTER DATABASE CHARACTER SET INTERNAL_USE AL32UTF8;
SQL>shutdown immediate;
SQL>startup;
SQL>select * from v$nls_parameters where parameter like '%CHARACTERSET';

No comments:

Post a Comment