The Db2® database manager does not support storing HKSCS (Hong Kong Supplementary Character Set) data in a
code page 950 database. HKSCS data is supported by using a Unicode database. HKSCS data may have
inadvertently been stored into a code page 950 database through a Windows client. The following steps provide a guideline to converting such
a 950 database to a Unicode database.
Before you begin
You
must use a code page 950 client for the first step of this procedure.
Using a code page 950 client ensures that no code page conversion
is done on the data and any HKSCS-2004 data remains intact. To set
your client code page to 950, set the DB2CODEPAGE registry variable
to 950 and execute the TERMINATE command.
About this task
The
generic method for converting databases to Unicode, described in the
section "Converting non-Unicode databases to Unicode databases" cannot
be used in this scenario, because that procedure uses the db2move command
and the IXF file format. The procedure described here requires the
DEL file format.
When converting a large database, load performance may be an issue. See the "Db2 Universal Database Version 8 Loader Performance" white
paper at ftp://ftp.software.ibm.com/software/data/pubs/papers/loaderperf.pdf. For
information about the Db2 High Performance
Unload (HPU) utility, see http://www.ibm.com/software/data/db2imstools/db2tools/db2hpu/.
Procedure
- Using a code page 950 client, connect to the code page
950 database and export your data from the code page 950 database
to a DEL file. Repeat the export operation for all user-created tables
in the code page 950 database.
connect to 950db
export to table1.del of del modified by lobsinfile select * from table1
export to table2.del of del modified by lobsinfile select * from table2
...
- Generate a DDL script for your existing code page 950 database
using the db2look command:
db2look -d 950db -e -o unidb.ddl -l -x -f
In this example, 950db is the existing database
name and unidb.ddl is the file name for the generated
DDL script. The -l option generates DDL for user
defined table spaces, database partition groups and buffer pools;
the -x option generates authorization DDL; and the -f option
generates an update command for database configuration parameters.
- Create the Unicode database:
create database unidb using codeset UTF-8 territory HK
- Edit the unidb.ddl script and change
all occurrences of the database name to the new Unicode database name.
You may also need to increase column lengths as expansion may
occur during code page conversion. Character data may expand by up
to 3 times the original size. Graphic data may expand by up to 2 times
the original size. To keep the existing code page 950 database, you
must also change the file name specification for table spaces in the unidb.ddl file.
- Connect to the Unicode database and re-create your database
structure by running the DDL script that you edited:
connect to unidb
db2 -tvf unidb.ddl
- Load or import your data into the new Unicode database.
- Load your data into the new Unicode database using the load command
with modified by codepage=1375 option. This will
cause the load command to treat your DEL file as
code page 1375 data and to convert it to Unicode data. You can use
a client with any code page for this step, because the load utility
connects directly to the database and is not affected by the client's
code page.
load from table1.del of del modified by codepage=1375 modified by lobsinfile
insert into table1
load from table2.del of del modified by codepage=1375 modified by lobsinfile
insert into table2
...
- Import your data into the new Unicode database using the import command
with modified by codepage=1375 option. This will
cause the import command to treat your DEL file
as code page 1375 data and to convert it to Unicode data.
import from table1.del of del modified by codepage=1375 modified by lobsinfile
insert into table1
import from table2.del of del modified by codepage=1375 modified by lobsinfile
insert into table2
...