13.16.2 Example 2: Migrating data to a table with a different table definition

This example moves (copies) the data from TABLE1 to TABLE2. The table definitions of TABLE1 and TABLE2 differ as follows:

[Figure]

Organization of this subsection
(1) Use the pdhold command to shut down RDAREAs to be unloaded and RDAREAs to be reloaded
(2) Create the control statements file for the pdrorg command
(3) Use the pdrorg command to unload data from TABLE01
(4) Create the column structure information file (/pdload/column01)
(5) Create the control statements file for the pdload command
(6) Use the pdload command to load data into TABLE02
(7) Back up the RDAREAs in which data was loaded
(8) Use the pdrels command to release RDAREAs from shutdown status

(1) Use the pdhold command to shut down RDAREAs to be unloaded and RDAREAs to be reloaded

pdhold -r RDAREA01,RDAREA02,...

(2) Create the control statements file for the pdrorg command

The contents of the control statements file (/pdrorg/rorg01) are shown below.

(a) HiRDB/Single Server

unload /pdrorg/unfile1                                1
unld_func type=sgmltext,func=unsgmltext(sgmltext)     2

Explanation
  1. Specifies the name of the unload data file.
  2. Specifies information on the constructor parameter reverse generation function, because the SGMLTEXT type is defined for the table.
(b) HiRDB/Parallel Server

unload bes1:/pdrorg/unfile1                          1
unld_func type=sgmltext,func=unsgmltext(sgmltext)    2

Explanation
  1. Specifies the name of the unload data file.
  2. Specifies information on the constructor parameter reverse generation function, because the SGMLTEXT type is defined for the table.

(3) Use the pdrorg command to unload data from TABLE01

pdrorg -k unld -W bin -j -t TABLE01 -g /pdrorg/rorg01

Explanation
-k: Specifies unld for unloading.
-W bin: Specifies use of the unload data file as the input file (binary format) for the pdload command.
-j: Specifies that a LOB column or a column with the LOB attribute is defined in the table that is to be unloaded.
-t: Specifies the name of the table that is to be unloaded.
-g: Specifies that TABLE01 is row-partitioned between servers in a HiRDB/Parallel Server. Specifying the -g option consolidates the unload data files (into a single file).
/pdrorg/rorg01: Specifies the name of the control statements file for the pdrorg command.

(4) Create the column structure information file (/pdload/column01)

*skipdata*,type=integer
C5
C6,func=(sgmltext,param=blob)
C7

Because the column structure of the input data file created in step (3) differs from the column structure of TABLE02, a column structure information file is needed for data loading. For an example of specifying a column structure information file, see 13.16.3 Specification examples of column structure information files.

(5) Create the control statements file for the pdload command

The contents of the control statements file (/pdload/load01) are shown below.

(a) HiRDB/Single Server

source /pdrorg/unfile1

Explanation
Specifies the name of the unload data file created in step (3).
(b) HiRDB/Parallel Server

source bes1:/pdrorg/unfile1

Explanation
Specifies the name of the unload data file created in step (3).

(6) Use the pdload command to load data into TABLE02

pdload -k d -b -W -c /pdload/column01 TABLE02 /pdload/load01

Explanation
-k d: Specifies that the input data contains BLOB data.
-b: Specifies that data in binary format is to be loaded.
-W: Specifies that an input data file in binary format, created with the pdrorg command, is to be used.
-c /pdload/column01: Specifies the name of the column structure information file created in step (4).
TABLE02: Specifies the name of the table into which the data is to be loaded.
/pdload/load01: Specifies the name of the control statements file for the pdload command.

(7) Back up the RDAREAs in which data was loaded

Because you loaded data in the pre-update acquisition mode (default), back up the RDAREAs in which data was loaded. For details about backing up RDAREAs, see 6.4.6 Example 6 (Backing up RDAREAs).

(8) Use the pdrels command to release RDAREAs from shutdown status

pdrels -r RDAREA01,RDAREA02,...

It is recommended that after the command has executed you check whether or not the execution results are correct. For details on how to check command execution results, see the manual HiRDB Version 8 Command Reference.