MainframeSupports
tip week 9/2009:

I assume you know that DB2 tables are stored in VSAM datasets. In the childhood of DB2 IBM invented a special kind of VSAM datasets called LDS (Linear Data Set) to store DB2 data in. But how do you determine which VSAM dataset your DB2 data are stored in. You may use the following SQL statement:

SELECT STRIP(P.VCATNAME)
    !! '.DSNDBC.' !! STRIP(P.DBNAME)
    !! '.' !! STRIP(P.TSNAME)
    !! '.' !! P.IPREFIX !! '0001'
    !! '.A'
    !! CASE P.PARTITION WHEN 0 THEN '001'
       ELSE SUBSTR(DIGITS(P.PARTITION), 3) END
FROM SYSIBM.SYSTABLES T, SYSIBM.SYSTABLEPART P
WHERE T.CREATOR = 'SYSIBM'
  AND T.NAME = 'SYSTABLES'
  AND T.DBNAME = P.DBNAME
  AND T.TSNAME = P.TSNAME

All you have to do is to replace SYSIBM with the creator of your DB2 table and SYSTABLES with the name of your table. If your table is partitioned the SQL statement will return the names of all the VSAM datasets your table is spread across. If your table is not partitioned it will return exactly one dataset name.

If your non-partitioned DB2 table becomes more than 2GB large DB2 will automatically create an extra VSAM dataset. If this extra VSAM dataset also grows beyound the 2GB limit yet another VSAM dataset is created and so on. The names of these extra VSAM datasets follows the same naming convention as partitioned DB2 tables, but there is no information stored in the DB2 catalog about these extra VSAM datasets. In other words the above SQL statement will not show these extra VSAM datasets if there are any.

A VSAM LDS consists of a cluster dataset and a data dataset. The SQL statement shows the name of the cluster dataset. You may alter the SQL statement to show the data dataset by replacing DSNDBC with DSNDBD. I always use DSNDBD because ISPF 3.4/DSLIST shows information about actual size and number of extents for the DSNDBD dataset. From a MVS point of view it is the cluster dataset that you use in file operations so therefore it is more correct to use the cluster name.

In DB2 version 8 and DB2 9 you can create DB2 tables with up to 4096 partitions. If you are running on DB2 version 8 or DB2 9 and your DB2 table has more than 255 partitions the above SQL statement will not return the correct result.

Previous tip in english        Sidste danske tip        Tip list