Nonstop Database, HiRDB Version 9 System Operation Guide

[Contents][Index][Back][Next]

12.1.9 Example 5: Migrating table data after expanding the column definition size of fixed-size character data

This example migrates a table (TABLE1) from HiRDB system A to HiRDB system B.

It is assumed that RDAREAs with the same names (RDAREA1 to RDAREA4) have already been created in the target system.

[Figure]

Organization of this subsection
(1) Enter the pdhold command to shut down RDAREA1 to RDAREA4
(2) Create a control statements file for the pdrorg command
(3) Use the pdrorg command to unload data for TABLE1
(4) Use the pdrels command to release RDAREA1 to RDAREA4 from shutdown status
(5) Store the unload data file and export file on a medium such as CMT
(6) Store the unload data file and export file in the target system
(7) Use the pddef command to define a schema for the user who owns TABLE1
(8) Swap the system log files
(9) Use the pdcopy command to back up data
(10) Use the pddef command to define TABLE1 with an expanded column definition size
(11) Use the pdhold command to shut down RDAREA1 to RDAREA4
(12) Create the column structure information file for the pdload command
(13) Create a control statements file for the pdload command
(14) Use the pdload command to load data for TABLE1
(15) Swap the system log files
(16) Enter the pdcopy command to back up data
(17) Use the pdrels command to release RDAREA1 to RDAREA4 from shutdown status

(1) Enter the pdhold command to shut down RDAREA1 to RDAREA4

 
pdhold -r RDAREA1,RDAREA2,RDAREA3,RDAREA4
 

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

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

(a) HiRDB single server configuration
 
unload /pdrorg/unfile1
 

Explanation
Specifies the name of the unload data file.
(b) HiRDB parallel server configuration
 
unload bes1:/pdrorg/unfile1
 

Explanation
Specifies the name of the unload data file (for bes1).

(3) Use the pdrorg command to unload data for TABLE1

 
pdrorg -k unld -g -W bin -t TABLE1 /pdrorg/rorg01
 

Explanation
-k: Specifies unld to unload data.
-g: Specifies that TABLE1 is a row-partitioned table on a server in a HiRDB parallel server configuration. A single unload data file is created.
-W: Specifies that an input data file for pdload is to be created. In this case, bin (binary format) is specified since TABLE1 contains a binary format column.
-t: Specifies the name of the table that is to be unloaded.
/pdrorg/rorg01: Specifies the name of the control statements file for the pdrorg command created in step (2).

(4) Use the pdrels command to release RDAREA1 to RDAREA4 from shutdown status

 
pdrels -r RDAREA1,RDAREA2,RDAREA3,RDAREA4
 

(5) Store the unload data file and export file on a medium such as CMT

The unload data file created in step (3) is stored on a medium such as CMT.

The operations at the source system (HiRDB system A) have now been completed.

(6) Store the unload data file and export file in the target system

The operations from this point on are performed at the target system (HiRDB system B).

The unload data file and export file stored on a medium such as CMT are copied to the target system.

(7) Use the pddef command to define a schema for the user who owns TABLE1

 
pddef
   CREATE SCHEMA AUTHORIZATION USR01;
 

(8) Swap the system log files

Before you acquire a backup, use the pdlogswap command to swap the system log files.

 
pdlogswap -d sys -w
 

Explanation
In the case of a HiRDB parallel server configuration, specify the -s option and execute the pdlogswap command for each server to be backed up.

(9) Use the pdcopy command to back up data

 
pdcopy -m /rdarea/mast/mast01 -M r
-r RDMAST,RDDIR,RDDIC,RDAREA1,RDAREA2,RDAREA3,RDAREA4
-b /pdcopy/backup01 -p /pdcopy/list01
 

Explanation
The RDAREAs are backed up as a safeguard against errors that might occur during database migration. The following RDAREAs must be backed up:
  • Master dictionary RDAREA
  • Data directory RDAREA
  • Data dictionary RDAREA
  • User RDAREAs and user LOB RDAREAs for storing the imported table (RDAREA1 to RDAREA4)
-m: Specifies the name of the first HiRDB file in the master directory RDAREA.
-M: Specifies the backup acquisition mode.
-r: Specifies the names of the RDAREAs to be backed up.
-b: Specifies the name of the backup file.
-p: Specifies the output destination for the pdcopy command's processing results listing.
For details about how to back up data, see 6. Backup Procedures.

(10) Use the pddef command to define TABLE1 with an expanded column definition size

 
pddef
   CREATE TABLE1 Product Table
     (product-code CHAR(10),
      product-image BLOB(10K),
     IN RDAREA3,RDAREA4
     ) IN RDAREA1,RDAREA2;
 

Explanation
The following shows the table definition at the source system:
 
CREATE TABLE1 Product Table
  (product-code CHAR(8),
   product-image BLOB(10K),
  IN RDAREA3,RDAREA4
  ) IN RDAREA1,RDAREA2
As you can see, the definition size of the product code column is expanded in the target system.

If TABLE1 is already defined in HiRDB system B, delete it using DROP TABLE, and then define a table.

(11) Use the pdhold command to shut down RDAREA1 to RDAREA4

 
pdhold -r RDAREA1,RDAREA2,RDAREA3,RDAREA4
 

(12) Create the column structure information file for the pdload command

The following are the contents of the column structure information file (/pdload/column01):

 
product-code,type=char(8)             1
product-image                         2

Explanation
  1. Specifies the column name and data type in the source system.
  2. Specifies the column name in the source system.

(13) Create a control statements file for the pdload command

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

(a) HiRDB single server configuration
 
source /pdrorg/unfile1                     1
idxwork /pdrorg/idxwork                    2
sort /sortwork                             3
 

Explanation
  1. Specifies the name of the unload data file.
  2. Specifies the name of the directory in which an index information file is to be created. The index information file is created under this directory.
  3. Specifies the name of the work directory for sorting.
(b) HiRDB parallel server configuration
 
unload bes1:/pdrorg/unfile1                 1
idxwork bes1 /pdrorg/idxwork                2
sort bes1 /sortwork                         3
idxwork bes2 /pdrorg/idxwork                4
sort bes2 /sortwork                         5
 

Explanation
  1. Specifies the name of the unload file (for bes1).
  2. Specifies the name of the directory in which an index information file is to be created (for bes1). The index information file is created under this directory.
  3. Specifies the name of the work directory for sorting (for bes1).
  4. Specifies the name of the directory in which an index information file is to be created (for bes2). The index information file is created under this directory.
  5. Specifies the name of the work directory for sorting (for bes2).

(14) Use the pdload command to load data for TABLE1

 
pdload -b -W -c /pdload/column01 TABLE1 /pdload/load01
 

Explanation
-b: Specifies -W to use as the input data file the file that was output in binary format when the -W option was specified for the pdrorg command.
-c: Specifies the column structure information file in order to change the column definition size.
/pdload/load01: Specifies the name of the control statements file for the pdload command created in step (13).

(15) Swap the system log files

Before you acquire a backup, use the pdlogswap command to swap the system log files.

 
pdlogswap -d sys -w
 

Explanation
In the case of a HiRDB parallel server configuration, specify the -s option and execute the pdlogswap command for each server to be backed up.

(16) Enter the pdcopy command to back up data

 
pdcopy -m /rdarea/mast/mast01 -M r
-r RDMAST,RDDIR,RDDIC,RDAREA1,RDAREA2,RDAREA3,RDAREA4
-b /pdcopy/backup02 -p /pdcopy/list02
 

Explanation
The following RDAREAs must be backed up:
  • Master dictionary RDAREA
  • Data directory RDAREA
  • Data dictionary RDAREA
  • User RDAREAs and user LOB RDAREAs for storing the imported table (RDAREA1 to RDAREA4)
-m: Specifies the name of the first HiRDB file in the master directory RDAREA.
-M: Specifies the backup acquisition mode.
-r: Specifies the names of the RDAREAs to be backed up.
-b: Specifies the name of the backup file.
-p: Specifies the output destination for the pdcopy command's processing results listing.
For details about how to back up data, see 6. Backup Procedures.

(17) Use the pdrels command to release RDAREA1 to RDAREA4 from shutdown status

 
pdrels -r RDAREA1,RDAREA2,RDAREA3,RDAREA4
 

We recommend that after the command has executed you check whether the execution results are correct. For details about how to check command execution results, see the manual HiRDB Version 9 Command Reference.