Defining data sets

DB2® checks whether you have defined your data sets correctly.

About this task

You must define a data set for each of the following items:

  • A simple or segmented table space
  • A partition of a partitioned table space
  • A partition of a partitioned index

You must define the data sets before you can issue the CREATE TABLESPACE, CREATE INDEX, or ALTER TABLE ADD PARTITION SQL statements.

If you create a partitioned table space, you must create a separate data set for each partition, or you must allocate space for each partition by using the PARTITION option of the NUMPARTS clause in the CREATE TABLESPACE statement.

If you create a partitioned secondary index, you must create a separate data set for each partition. Alternatively, for DB2 to manage your data sets, you must allocate space for each partition by using the PARTITIONED option of the CREATE INDEX statement.

If you create a partitioning index that is partitioned, you must create a separate data set for each partition. Alternatively, for DB2 to manage your data sets, you must allocate space for each partition by using the PARTITIONED option or the PARTITION ENDING AT clause of the CREATE INDEX statement in the case of index-controlled partitioning.

Procedure

To define and manage VSAM data sets yourself:

  1. Issue a DEFINE CLUSTER statement to create the data set.
  2. Give each data set a name that complies with the following format:
    catname.DSNDBx.dbname.psname.y0001.znnn
  3. In the DEFINE CLUSTER statement, specify the size of the primary and secondary extents of the VSAM cluster. If you specify zero for the secondary extent size, data set extension does not occur.
  4. Specify that the data sets be LINEAR. Do not use RECORDSIZE; this attribute is invalid. Use the CONTROLINTERVALSIZE attribute if you are using variable-sized control intervals.
  5. Specify the REUSE option. You must define the data set as REUSE before running the DSN1COPY utility.
  6. Use SHAREOPTIONS(3,3).

Example

The following example code shows an example of the DEFINE CLUSTER command, which defines a VSAM data set for the SYSUSER table space in database DSNDB06. Assume that an integrated catalog facility catalog named DSNCAT is already defined.

DEFINE CLUSTER -
       (NAME(DSNCAT.DSNDBC.DSNDB06.SYSUSER.I0001.A001) -
        LINEAR                                         -
        REUSE                                          -
        VOLUMES(DSNV01)                                -
        RECORDS(100 100)                               -
        SHAREOPTIONS(3 3) )                            -
      DATA                                             -
       (NAME(DSNCAT.DSNDBD.DSNDB06.SYSUSER.I0001.A001) -
    CATALOG(DSNCAT)

For user-managed data sets, you must pre-allocate shadow data sets prior to running the following against the table space:

  • REORG with SHRLEVEL CHANGE
  • REORG with SHRLEVEL REFERENCE
  • CHECK INDEX with SHRLEVEL CHANGE
  • CHECK DATA with SHRLEVEL CHANGE
  • CHECK LOB with SHRLEVEL CHANGE

You can specify the MODEL option for the DEFINE CLUSTER command so that the shadow is created like the original data set, as shown in the following example code.

DEFINE CLUSTER -
       (NAME('DSNCAT.DSNDBC.DSNDB06.SYSUSER.x0001.A001') -
       MODEL('DSNCAT.DSNDBC.DSNDB06.SYSUSER.y0001.A001')) -
      DATA                                                -
       (NAME('DSNCAT.DSNDBD.DSNDB06.SYSUSER.x0001.A001') -
       MODEL('DSNCAT.DSNDBD.DSNDB06.SYSUSER.y0001.A001')) -
    

In the previous example, the instance qualifiers x and y are distinct and are equal to either I or J. You must determine the correct instance qualifier to use for a shadow data set by querying the DB2 catalog for the database and table space.

What to do next

The DEFINE CLUSTER command has many optional parameters that do not apply when DB2 uses the data set. If you use the parameters SPANNED, EXCEPTIONEXIT, BUFFERSPACE, or WRITECHECK, VSAM applies them to your data set, but DB2 ignores them when it accesses the data set.

The value of the OWNER parameter for clusters that are defined for storage groups is the first SYSADM authorization ID specified at installation.

When you drop indexes or table spaces for which you defined the data sets, you must delete the data sets unless you want to reuse them. To reuse a data set, first commit, and then create a new table space or index with the same name. When DB2 uses the new object, it overwrites the old information with new information, which destroys the old data.

Likewise, if you delete data sets, you must drop the corresponding table spaces and indexes; DB2 does not drop these objects automatically.