12.1.2 Example 1: Migrating a table
(1) Enter the pdhold command to shut down RDAREA1 to RDAREA6
pdhold -r RDAREA1,RDAREA2,RDAREA3,RDAREA4,RDAREA5,RDAREA6 |
(2) Create the control statements file for the pdrorg command
The following are the contents of the control statements file (/pdrorg/rorg01):
(a) HiRDB/Single Server
- Explanation
- Specifies the name of the unload data file.
(b) HiRDB/Parallel Server
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 -j -g -t TABLE1 /pdrorg/rorg01 |
- Explanation
- -k: Specifies unld in order to unload data.
- -j: Specifies that the table that is to be unloaded is one of the following:
- A table containing a LOB column
- A table in which an abstract data type with the LOB attribute is defined
- -g: Specifies that TABLE1 is a row-partitioned table on a server of the HiRDB/Parallel Server. A single unload data file is created.
- -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 RDAREA6 from shutdown status
pdrels -r RDAREA1,RDAREA2,RDAREA3,RDAREA4,RDAREA5,RDAREA6 |
(5) Create the control statements file for the pdexp command
The following are the contents of the control statements file (/pdexp/exp01):
- Explanation
- USR01: Name of the schema that owns TABLE1.
- TABLE1: Name of the table to be exported.
(6) Use the pdexp command to export table definition information for TABLE1
pdexp -e /pdexp/expfile1 -f /pdexp/exp01 |
- Explanation
- -e: Specifies the name of the file to be exported.
- -f: Specifies the name of the control statements file for the pdexp command created in step (5).
(7) Store the unload data file and export file on a medium such as CMT
The unload data file created in step (3) and the export file created in step (6) are stored on a medium such as CMT.
The operations at the source system (HiRDB system A) are now complete.
(8) 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 into the target system.
(9) Use the pddef command to define a schema for the user who owns TABLE1
pddef
CREATE SCHEMA AUTHORIZATION USR01; |
(10) Use pdcopy command to back up the data
pdcopy -m /rdarea/mast/mast01 -M r
-r RDMAST,RDDIR,RDDIC,RDAREA1,RDAREA2,RDAREA3,RDAREA4,RDAREA5,RDAREA6
-b /pdcopy/backup01 -p /pdcopy/list01 |
- Explanation
- The RDAREAs are backed up as a safeguard in the event of errors during database migration. The following RDAREAs must be backed up:
- Master directory RDAREA
- Data directory RDAREA
- Data dictionary RDAREAs
- User RDAREAs and user LOB RDAREAs for storing the imported table (RDAREA1 to RDAREA6)
- -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.
(11) Use the pdexp command to import table definition information for TABLE1
- Explanation
- -i: Specifies the name of the file to be imported.
(12) Use the pdhold command to shut down RDAREA1 to RDAREA6
pdhold -r RDAREA1,RDAREA2,RDAREA3,RDAREA4,RDAREA5,RDAREA6 |
(13) Create the control statements file for the pdrorg command
The following are the contents of the control statements file (/pdrorg/rorg01):
(a) HiRDB/Single Server
unload /pdrorg/unfile1 1
idxwork /pdrorg/idxwork 2
sort /sortwork,8192 3 |
- Explanation
- Specifies the name of the unload data file.
- Specifies the name of the directory in which to create an index information file. The index information file is created under this directory.
- Specifies the name of the work directory for sorting.
(b) HiRDB/Parallel Server
unload bes1:/pdrorg/unfile1 1
idxwork bes1 /pdrorg/idxwork 2
sort bes1 /sortwork,8192 3
idxwork bes2 /pdrorg/idxwork 4
sort bes2 /sortwork,8192 5 |
- Explanation
- Specifies the name of the unload data file (for bes1).
- 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.
- Specifies the name of the work directory for sorting (for bes1).
- 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.
- Specifies the name of the work directory for sorting (for bes2).
(14) Use the pdrorg command to reload data for TABLE1
pdrorg -k reld -j -g -t TABLE1 /pdrorg/rorg01 |
- Explanation
- To re-create the index (INDEX1) at the same time, the -i option is omitted and the index batch creation mode is used.
- -k: Specifies reld in order to reload data.
- -j: Specifies that the table that is to be reloaded is one of the following:
- A table containing a LOB column
- A table in which an abstract data type with the LOB attribute is defined
- -g: Specifies that TABLE1 is a row-partitioned table on a server of the HiRDB/Parallel Server. A single unload data file is created.
- -t: Specifies the name of the table to be reloaded.
- /pdrorg/rorg01: Specifies the name of the control statements file for the pdrorg command created in step (13).
(15) Use the pdcopy command to back up the data
pdcopy -m /rdarea/mast/mast01 -M r
-r RDMAST,RDDIR,RDDIC,RDAREA1,RDAREA2,RDAREA3,RDAREA4,RDAREA5,RDAREA6
-b /pdcopy/backup02 -p /pdcopy/list02 |
- Explanation
- The following RDAREAs must be backed up:
- Master directory RDAREA
- Data directory RDAREA
- Data dictionary RDAREAs
- User RDAREAs and user LOB RDAREAs for storing the imported table (RDAREA1 to RDAREA6)
- -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 of the pdcopy command's processing results listing.
(16) Use the pdrels command to release RDAREA1 to RDAREA6 from shutdown status
pdrels -r RDAREA1,RDAREA2,RDAREA3,RDAREA4,RDAREA5,RDAREA6 |
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.