DB2 Server for VSE & VM: Data Restore Guide


Step 2. Reload Procedures

When a table has been corrupted by a program or accidentally dropped, you may have to restore that table. The following sections show the possibilities for reloading a table.

The database server must be active to reload tables, and applications using the server cannot access any table being reloaded during the reload process.
Note:The System Catalog tables cannot be reloaded.

Figure 105. The RELOAD Function


fig89

Notes:

  1. RELOAD can be used with BACKUP, UNLOAD, or DB2 Server for VSE & VM archive files.

  2. The DB2 Server for VSE & VM database consists of the directory, all dbextents, and the log.

  3. The SYSIN file will contain the list of tables to be restored with all the required parameters.

Using the RELOAD Command

To reload tables you use the RELOAD command.

The RELOAD function may also reload a table from one database to another. Specify the name of the source database on the CONTROL statement (parameter DBNAME) to verify that the file was produced from that database. If you are reloading directly from a DB2 Server for VSE & VM archive, specify ARCHTYPE=DB2 on the OPTIONS statement. If you are reloading from a translated DB2 Server for VSE & VM archive file, include the FILEDEFs or DLBLs for the DIRWORK, HEADER and SYS0001 files produced by the TRANSLATE function.

Reload a Table after Deleting Existing Rows

Sometimes you want to reload a table without keeping its current contents. To delete all of the rows in the table before starting the RELOAD process, specify PURGE for the FUNCT parameter.

You can execute this process from an UNLOAD or BACKUP file or from a DB2 Server for VSE & VM database archive file.

Figure 106. RELOADing a Table with the PURGE Parameter


fig91

Reload a New Table

Sometimes you want to reload a table that does not exist in the database (for example, a DROP table has been issued, or you are reloading into a different database) or you just want to reload into a table with a different name. Data Restore creates the table before reloading rows if you specify NEW for the FUNCT parameter and specify the DBSPACE where the table is to be created (using the DBSPACE parameter).
Note:For private dbspaces you must specify on owner (on the OWNER parameter).

You can execute this process from an UNLOAD or BACKUP file or from an DB2 Server for VSE & VM database archive file.

Figure 107. RELOADing a Table with the NEW Parameter


fig92

Reload Rows into an Existing Table

Sometimes you want to add new rows to an existing table from a BACKUP or UNLOAD file. To do this, specify ADD for the FUNCT parameter.

You can execute this process from an UNLOAD or BACKUP file or from an DB2 Server for VSE & VM database archive file.

Figure 108. RELOADing a Table with the ADD Parameter


fig93

Reload a Table with Full Environment Recreation

Specify REPLACE for the FUNCT parameter to recreate the full environment on the table you want to reload.

If you specify REPLACE and the target table is the same as the source table (NEWTNAME and NEWCREATOR are not specified), the entire environment including indexes, referential integrity, views, grants, comments, and labels is recreated after the data are reloaded.

You can execute this process from an UNLOAD or BACKUP file or from an DB2 Server for VSE & VM database archive file.

Figure 109. RELOADing a Table with the REPLACE Parameter


fig94

All of the commands for environment recreation will be displayed on SYSPRINT or SYSLST.

Figure 110. Example List Displayed for a RELOAD with the REPLACE Parameter

XTS9-143 CONTROL DBNAME=dbname  CONFIRM=NO
XTS9-143 OPTIONS COMMITCOUNT=600 CASE=M
XTS9-143 RELOAD  CREATOR=SQLDBA  TNAME=T1  FUNCT=REPLACE
XTS9-143 /*
XTS9-100 Data Restore feature VERSION 7.1.0
XTS9-136 Processing BASE1    archived on (11/10/94-15:19:11)
XTS9-127       600 rows loaded procedure  continuing
XTS9-127      1200 rows loaded procedure  continuing
XTS9-127      1800 rows loaded procedure  continuing
XTS9-127      2400 rows loaded procedure  continuing
XTS9-102      2650 rows loaded procedure  completed
XTS9-128         5 rows loaded into (SQLDBA.T1)
XTS9-128       933 rows loaded into (DATARFTR.SYSCOLUMNS)
XTS9-128       108 rows loaded into (DATARFTR.SYSCATALOG)
XTS9-128       693 rows loaded into (DATARFTR.SYSTABAUTH)
XTS9-128       106 rows loaded into (DATARFTR.SYSINDEXES)
XTS9-128        19 rows loaded into (DATARFTR.SYSVIEWS)
XTS9-128        14 rows loaded into (DATARFTR.SYSKEYCOLS)
XTS9-128        14 rows loaded into (DATARFTR.SYSKEYS)
XTS9-128       719 rows loaded into (DATARFTR.SYSUSAGE)
XTS9-128        39 rows loaded into (DATARFTR.SYSCOLAUTH)
XTS9-101        10 tables successfully processed
XTS9-314 Commit work successful for reload of data, creating required objects
ALTER TABLE "SQLDBA"."T1" ADD PRIMARY KEY ("C1" DESC) PCTFREE=10;
CREATE UNIQUE INDEX "SQLDBA"."IND1" ON "SQLDBA"."T1" ("C1" ASC ) PCTFREE=10;
ALTER TABLE "SQLDBA"."T1" ADD FOREIGN KEY "FOREIGNT2" ("C2")
REFERENCES "SQLDBA"."T2" ON DELETE RESTRICT;
COMMIT WORK ;
CONNECT SQLDBA  ;
GRANT SELECT ON "SQLDBA"."T1" TO "PAUL" WITH GRANT OPTION;
COMMIT WORK ;
CONNECT PAUL    ;
CREATE VIEW V1 AS SELECT * FROM SQLDBA.T1;
GRANT SELECT ON "PAUL"."V1" TO "GEORGE" WITH GRANT OPTION;
CREATE VIEW VV1 AS SELECT A.C1 FROM PAUL.V1 A,PAUL.V2 B WHERE  A.C1 = B.C2;
GRANT SELECT ON "PAUL"."VV1" TO "JOHN";
COMMIT WORK ;
CONNECT SQLDBA  ;
COMMENT ON TABLE "SQLDBA"."T1" IS 'TABLE T1';
COMMENT ON COLUMN "SQLDBA"."T1"."C1" IS 'COLUMN C1';
LABEL ON COLUMN "SQLDBA"."T1"."C1" IS '""';
COMMIT WORK ;
XTS9-007 Processing successfully completed

To recreate the environment, Data Restore creates copies of some of the System Catalog tables, using DATARFTR as the creator name; for example, information from SYSTEM.SYSCATALOG is loaded into DATARFTR.SYSCATALOG.

Reload Tables With Forward Recovery From the Log

When you reload a table from a BACKUP or a DB2 Server for VSE & VM archive file, the reloaded table does not contain any of the changes made on that table after the backup was taken. Those changes are recorded in any log archives taken since the backup and in the current log.

If you want to reload a table and apply the changes, specify RECOVERY=YES on the OPTIONS statement (refer to OPTIONS and CONTROL Statements) during the RELOAD process. Refer to the next sections for information on listing and applying the changes in the log.

Notes:

  1. This function is available for BACKUP or DB2 Server for VSE & VM archive files processed when the server was running in LOGMODE A or L.

  2. Forward Recovery can only be applied to tables that exist in the archive that is being used for the RELOAD.

  3. Forward log recovery stops when it encounters a DROP TABLE or DROP DBSPACE command in the log.

  4. If dual logging is being used, Data Restore will switch to the secondary log if there is an error processing the primary log.

Figure 111. Possible Input Sources for RELOADing Tables with Forward Recovery


fig99

Figure 112. Example of JCL to Reload in a VSE Environment From a Full Backup

        // JOB RELOAD
(1) ---> // LIBDEF *,SEARCH=(PRD2.DB2vrm,PRD2.RCVvrm)
(2) ---> // DLBL LMBRWRK,,,VSAM
(3) ---> // TLBL ARCHIV,'ARCHIVE.SQL',,,1
(4) ---> // ASSGN SYS006,180
(5) ---> // MTC REW,SYS006
(5) ---> // EXEC XTS91001,SIZE=AUTO,PARM='DBNAME(DBNAME)'
(7) ---> CONTROL DBNAME=DBNAME
(7) ---> OPTIONS DEVICE=TAPE
(7) ---> RELOAD CREATOR=SQLDBA TNAME=CUSTOMERS FUNCT=PURGE
(7) ---> RELOAD CREATOR=SQLDBA TNAME=SUPPLIERS
(7) --->        FUNCT=NEW
(7) --->        NEWTNAME=NEWSUPPLIERS
(7) --->        DBSPACE=SAMPLE
        /*

Statement 1
DB2 library must be specified for the RELOAD function.

Statement 2
LMBRWRK is used if the reloaded tables contain LONG columns.

Statement 3
ARCHIV is the ddname for the BACKUP file. It can be a BACKUP file or a FULL BACKUP.

Statement 4
The tape containing the backup file is assigned.

Statement 5
The tape is rewound.

Statement 6
Program to execute functions is called. The DBNAME of the database to process must be specified on the PARM option.

Statement 7
SYSIN for the program is specified.

Figure 113. Example of JCL to Reload in a VSE Environment From an Incremental Backup

          // JOB RELOAD
(1) ---> // LIBDEF *,SEARCH=(PRD2.DB2vrm,PRD2.RCVvrm)
(2) ---> // DLBL LMBRWRK,,,VSAM
(3) ---> // TLBL ARCHIV,'ARCHIVE.SQL',,,1
(4) ---> // TLBL FULLARC,'ARCHIVE.SQL',,,1
(5) ---> // ASSGN SYS006,180
(6) ---> // MTC REW,SYS006
(7) ---> // EXEC XTS91001,SIZE=AUTO,PARM='DBNAME(dbname)'
(8) ---> CONTROL DBNAME=dbname WRKSIZE=4096
(8) ---> OPTIONS DEVICE=TAPE DEVICE2=TAPE
(8) ---> RELOAD CREATOR=SQLDBA TNAME=CUSTOMERS FUNCT=PURGE
(8) ---> RELOAD CREATOR=SQLDBA TNAME=SUPPLIERS
(8) --->        FUNCT=NEW
(8) --->        NEWTNAME=NEWSUPPLIERS
(8) --->        DBSPACE=SAMPLE
         /*

Statement 1
DB2 library must be specified for the RELOAD function.

Statement 2
LMBRWRK is used if the reloaded tables contain LONG columns.

Statement 3
ARCHIV is the ddname for the last Incremental Backup.

Statement 4
FULLARC is the ddname for the last Full Backup.

Statement 5
The tape containing the backup file is assigned.

Statement 6
The tape is rewound.

Statement 7
Program to execute functions is called. The DBNAME of the database to process must be specified on the PARM option.

Statement 8
SYSIN for the program is specified. WRKSIZE must be equivalent to the parameter specified during the BACKUP function. DEVICE2 specifies if a TAPE or DASD (TLBL/DLBL) is used for Full Backup (FULLARC).

Figure 114. Example of JCL to Reload in a VSE Environment From a DB2 Archive

          // JOB RELOAD
(1) ---> // LIBDEF *,SEARCH=(PRD2.DB2vrm,PRD2.RCVvrm)
(2) ---> // DLBL LMBRWRK,,,VSAM
(3) ---> // DLBL LMBRLG1,,,VSAM
(3) ---> // DLBL LMBRLG2,,,VSAM
(3) ---> // DLBL LMBRLG3,,,VSAM
(4) ---> // DLBL ARCHIV,,,VSAM
(5) ---> // TLBL LARCHIV,,,,1
(6) ---> // TLBL ARIARCH,'ARCHIVE.SQL',,,1
(7) ---> // ASSGN  SYS006, 180
(8) ---> // MTC REW,SYS006
(9) ---> // DLBL SYS0001,,,VSAM
(9) ---> // DLBL HEADER,,,VSAM
(9) ---> // DLBL DIRWORK,,,VSAM
(10) --->  // EXEC XTS91001,SIZE=AUTO,PARM='DBNAME(dbname)'
(11) --->  OPTIONS  ARCHTYPE=SQLDS
(11) --->  CONTROL  DBNAME=dbname
(11) --->  RELOAD  CREATOR=SQLDBA,TNAME=CUSTOMERS FUNCT=NEW
(11) --->  DBSPACE=SAMPLE
 

Statement 1
DB2 library must be specified for the RELOAD function.

Statement 2
LMBRWRK is used if the reloaded tables contain LONG columns.

Statement 3
LMBRLG1, LMBRLG2, and LBMRLG3 are used to extract all referenced in log files for the reloaded tables when RECOVERY=YES parameter is specified. They will be used to execute forward log recovery.

Statement 4
ARCHIV is the work file for this process.

Statement 5
LARCHIV is the ddname for the Log archive files.

Statement 6
ARIARCH is the ddname for the DB2 database archive file.

Statement 7
The tape containing the archive file is assigned.

Statement 8
The tape is rewound.

Statement 9
SYS0001, HEADER, DIRWORD are work files for the function.

Statement 10
Program to execute functions is called. The DBNAME of the DBNAME of the database to process must be specified on PARM option.

Statement 11
SYSIN for the program is specified. OPTIONS statement specifies that process is executed from DB2 database archive.

Figure 115. Example of VM Procedure to Reload From a Backup File

/**/
'TAPE REW'
'FILEDEF ARCHIV TAP1 SL 1 (RECFM VB BLOCK 32760'
'FILEDEF LMBRWRK DISK LMBRWRK DATA A (RECFM FB BLOCK 28672 LRECL 4096'
'FILEDEF SYSPRINT DISK RELOAD SYSPRINT A'
'FILEDEF SYSIN DISK RELOAD SYSIN A'
'XEDIT RELOAD SYSIN A'
'XTS91001'
 
 
 SYSIN file must contain the following statements :
 
 CONTROL DBNAME=dbname
 RELOAD CREATOR=SQLDBA TNAME=CUSTOMERS FUNCT=PURGE
 RELOAD CREATOR=SQLDBA TNAME=SUPPLIERS
    FUNCT=NEW
    NEWTNAME=NEWSUPPLIERS
 

Figure 116. Example of VM Procedure to Reload From an Incremental Backup

/**/
'TAPE REW'
'FILEDEF ARCHIV TAP1 SL 1 (RECFM VB BLOCK 32760'
'FILEDEF FULLARC TAP1 SL1 (RECFM VB BLOCK 32760'
'FILEDEF LMBRWRK DISK LMBRWRK DATA A (RECFM FB BLOCK 28672 LRECL 4096'
'FILEDEF SYSPRINT DISK RELOAD SYSPRINT A'
'FILEDEF SYSIN DISK RELOAD SYSIN A'
'XEDIT RELOAD SYSIN A'
'XTS91001'
 
SYSIN file must contain the following statements :
 
OPTIONS WRKSIZE=4096 DEVICE2=TAPE
CONTROL DBNAME=dbname
RELOAD CREATOR=SQLDBA TNAME=CUSTOMERS FUNCT=PURGE
RELOAD CREATOR=SQLDBA TNAME=SUPPLIERS
   FUNCT=NEW
   NEWTNAME=NEWSUPPLIERS
   DBSPACE=SAMPLE
 

Figure 117. Example of VM Procedure to Reload From a DB2 Archive

        /**/
(1) ---> 'FI LMBRLG1 DISK LMBRLG1 DATA A (RECFM VB BLOCK 32760'
        'FI LMBRLG2 DISK LMBRLG2 DATA A (RECFM VB BLOCK 32760'
        'FI LMBRLG3 DISK LMBRLG3 DATA A (RECFM VB BLOCK 32760'
(2) ---> 'FI ARIARCH TAP1 SL (RECFM FB BLOCK 28672 LRECL 4096'
(3) ---> 'FI ARCHIV DISK ARCHIV DATA  G (RECFM VB BLOCK 32760'
(4) ---> 'FI LARCHIV DISK BASE2 LOGDSK1  A1(RECFM F BLOCK 4096'
(5) ---> 'FI LMBRWRK DISK LMBRWRK DATA H (RECFM FB BLOCK 28672
         LRECL 4096'
(6) ---> 'FI SYS0001 DISK SYS0001 DATA H(RECFM F BLOCK 4096'
(7) ---> 'FI HEADER  DISK HEADER  DATA H(RECFM F BLOCK 4096'
(8) ---> 'FI DIRWORK DISK DIRWORK DATA H(RECFM F BLOCK 0512'
(9) ---> 'FI SYSIN DISK RELOAD   SYSIN  A'
        'FI SYSPRINT DISK RELOAD   SYSPRINT A'
        'XEDIT RELOAD SYSIN A'
        'XTS91001'                           /*Call BACKUP/RESTORE*/
 

Statement 1
LMBRLG1, LMBRLG2, LMBRLG3 files are used for recovery processing.

Statement 2
Defines the virtual tape drive for SQL/DS archive file.

Statement 3
Defines a work file. This file will contain on SQLDA per reloadable table.

Statement 4
Defines the database log file.

Statement 5
Defines the work file to process function.

Statement 6
Defines the file to contain all pages for dbspace SYS0001

Statement 7
Defines the file to contain all header pages.

Statement 8
Defines the files to contain all directory pages.

Statement 9
Defines the SYSIN file.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]