Change Database Character Encoding under Oracle.

** There is an immediately way at the end of this document. But I strongly recommended you to read this document line by line.


The approaches are:
Migrating Character Data Using a Full Export and Import
Migrating Character Data Using the ALTER DATABASE CHARACTER SET Statement
Migrating Character Data Using the ALTER DATABASE CHARACTER SET Statement and Selective Imports


The ALTER DATABASE CHARACTER SET statement is the fastest way to migrate a character set, but it can be used only under special circumstances. The ALTER DATABASE CHARACTER SET statement does not perform any data conversion, so it can be used if and only if the new character set is a strict superset of the current character set.

The new character set is a strict superset of the current character set if:
Each and every character in the current character set is available in the new character set.
Each and every character in the current character set has the same code point value in the new character set. For example, US7ASCII is a strict subset of many character sets.

Another restriction of the ALTER DATABASE CHARACTER SET statement is that it can be used only when the character set migration is between two single-byte character sets or between two multibyte character sets. If the planned character set migration is from a single-byte character set to a multibyte character set, then use the Export and Import utilities.

This restriction on using the ALTER DATABASE CHARACTER SET statement arises because of CLOB data. In Oracle9i, some internal fields in the data dictionary are stored in CLOB columns. Customers may also store data in CLOB fields. When the database character set is multibyte, CLOB data in Oracle9i is stored as UCS-2 data (two-byte, fixed-width Unicode). When the database character set is single-byte, CLOB data is stored using the database character set. Because the ALTER DATABASE CHARACTER SET statement does not convert data, CLOB columns remain in the original database character set encoding when the database character set is migrated from single-byte to multibyte. This introduces data inconsistency in the CLOB columns.

The syntax of the ALTER DATABASE CHARACTER SET statement is as follows:

ALTER DATABASE [db_name] CHARACTER SET new_character_set;

db_name is optional. The character set name should be specified without quotes. For example:

ALTER DATABASE CHARACTER SET AL32UTF8;

To change the database character set, perform the following steps:

Shut down the database, using either a SHUTDOWN IMMEDIATE or a SHUTDOWN NORMAL statement.
Do a full backup of the database because the ALTER DATABASE CHARACTER SET statement cannot be rolled back.

Complete the following statements:
STARTUP MOUNT;
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 new_character_set;
SHUTDOWN IMMEDIATE; -- or SHUTDOWN NORMAL;
STARTUP;

你可能感兴趣的:(oracle)