Rebuilding selected table spaces

Rebuilding a database allows you to build a database that contains a subset of the table spaces that make up the original database.

About this task

Rebuilding only a subset of table spaces within a database can be useful in the following situations:
  • In a test and development environment in which you want to work on only a subset of table spaces.
  • In a recovery situation in which you need to bring table spaces that are more critical online faster than others, you can first restore a subset of table spaces then restore other table spaces at a later time.

To rebuild a database that contains a subset of the table spaces that make up the original database, consider the following example.

In this example, there is a database named SAMPLE that has the following table spaces:
  • SYSCATSPACE (system catalogs)
  • USERSP1 (user data table space)
  • USERSP2 (user data table space)
  • USERSP3 (user data table space)
Figure 1 shows that the following backups have been taken:
  • BK1 is a backup of SYSCATSPACE and USERSP1
  • BK2 is a backup of USERSP2 and USERSP3
  • BK3 is a backup of USERSP3
Figure 1. Backup images available for database SAMPLE
Diagram showing the backups of database SAMPLE, and the backup log sequence (or log chain)
The following procedure demonstrates using the RESTORE DATABASE and ROLLFORWARD DATABASE commands, issued through the CLP, to rebuild just SYSCATSPACE and USERSP1 to end of logs:
db2 restore db mydb rebuild with all tablespaces in image
        taken at BK1 without prompting    
db2 rollforward db mydb to end of logs                
db2 rollforward db mydb stop 

At this point the database is connectable and only SYSCATSPACE and USERSP1 are in NORMAL state. USERSP2 and USERSP3 are in restore-pending state. You can still restore USERSP2 and USERSP3 at a later time.