To prevent Db2 from running out
of table space version numbers, and to prevent subsequent ALTER statements from failing, you must
remove unneeded, in-use table space versions regularly.
About this task
Db2 can store up to 256 table space
versions, numbered sequentially from 0 to 255. The next consecutive version number after 255 is 1.
Version number 0 is never reused; it is reserved for the original version of the table space. The
versions are associated with schema changes that have not been applied, but are considered to be in
use. The range of used versions is stored in the catalog.
If a table space has multiple tables, and one
table is at version number 0, the oldest table space version is 0. When the current table space
version reaches 255, you need to perform special processing to allow removal of table space
versions.
Procedure
To remove in-use table space versions:
-
Determine the range of version numbers that are currently in use for a table space by querying
the OLDEST_VERSION and CURRENT_VERSION columns of the SYSIBM.SYSTABLESPACE catalog table.
Version numbers are considered to be unused if the schema changes that are associated with them
have been applied, and there are no image copies that contain data at those versions.
-
If all reusable version numbers (1 to 255) are currently
in use, decrease the number of in-use versions by following these steps:
-
Perform this step only if the table space contains at least one table at version 0. Run the
REPAIR utility with the INSERTVERSIONPAGES and SETCURRENTVERSION options to update the version
number for the tables that are at version 0 to the current version number of the table space.
-
Reorganize the table space by running the REORG TABLESPACE utility. Doing this converts all
data in the table space to the format of the current version, and sets OLDEST_VERSION to
CURRENT_VERSION, to indicate that there is only one in-use version.
-
Remove all image copies of the table space by running the MODIFY RECOVERY utility:
MODIFY RECOVERY TABLESPACE table-space-name DSNUM ALL DELETE AGE(*)
Doing this ensures that there are no image copies with in-use versions.