Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RECOVERY OF ACCIDENTALLY DROPPED TABLES

Database Backup/Restore

RECOVERY OF ACCIDENTALLY DROPPED TABLES

by  sathyarams  Posted    (Edited  )


1. Setup the database for Table recovery

1) The archival logging should be tuned on.

2) The tablespace should be created with DROPPED TABLE RECOVERY ON.
If this was not done during creation of the tablespace it can be done with ALTER TABLESPACE Statement.
ALTER TABLESPACE <tablespace-name> DROPPED TABLE RECOVERY ON

2. Procedure

To recover an accidentally dropped table:

1) List the history file to get information about the dropped table id and the DDL to create the table.

DB2 LIST HISTORY DROPPED TABLE <qualified table-name> FOR <database name>

From the listing get the backup id and the DDL for table creation.

2) Restore the database from the backup image available using the RESTORE backup command. This can be either database level restore or a tablespace level restore.

3) Rollforward the database/tablespace to end of logs or point in time using RECOVER DROPPED TABLE option.
ROLLFORWARD DATABASE <db-name> TO END OF LOGS AND COMPLETE RECOVER DROPPED TABLE <backup-id> to <path>

To a Point-in-Time can be used instead of TO END OF LOGS.
Backup-id is the one obtained from the list history command.
Path is where the file containing the rows of the dropped table is to be put.

4) Create the table by using the DDL in the output of the LIST HISTORY command

5) Import the data from the file named ædataÆ in æpathÆ

If more than one dropped table is the recovered the Rollforward process is to be repeated for each table. In this case, do not include æAND COMPLETEÆ option of the ROLLFORWARD command except for the last table.

Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top