X = "select trim(tnt.dbsname) dbsname,"
X . " trim(tnt.owner) owner,"
X . " trim(tnt.tabname) tabname,"
X . " trim(tnt.dbsname) || ':' || trim(tnt.owner) || '.'"
X . " || trim(tnt.tabname) full_name,"
X . " 'T' partn_type,"
X . " tnt.partnum partition," # partnum of table or fragment"
X . " ph.lockid," # partn of 1st table fragment
X . " trim(ds.name) dbspace," # Name of dbspace hosting the partition
X . " ph.nrows," # Row count
X . " ph.nextns," # Number of extents
X . " (ph.pagesize/1024) pagesize," # Size of a page, in KB
X . " ph.nptotal," # How many pages allocated to partn?
X . " ph.npused" # How many pages are really occupied?
X . " from systabnames tnt,"
X . " sysptnhdr ph,"
X . " sysdbspaces ds"
X . " where ( ph.partnum = ph.lockid" # First table partition"
X . " or ph.nkeys != 1)" # OR another table partition"
X . " and tnt.partnum = ph.partnum"
X . " and ph.dbsnum = ds.dbsnum"
X . " and ds.is_sbspace = 0" # Smart-dbspace have no place here
X . " %DBSNAME%" # In case caller specified only for
X . " %TABLE%" # a database, table, or partition
X . " %PARTNUM%"
X . " %NOSYSTEM%" # Likely will sub with clause to skip system databases
X . " %NOTBLSPACE%" # In case caller specified only for
X . " %NOCATALOGS%" # a database, table, or partition
X . " %NOTEMPS%"
X . " union " # Now for the index partitions
X . "select trim(tni.dbsname) dbsname,"
X . " trim(tni.owner) owner,"
X . " trim(tnt.tabname) || '(' || trim(tni.tabname) || ')' tabname,"
X . " trim(tnt.dbsname) || ':' || trim(tnt.owner) || '.'"
X . " || trim(tnt.tabname) || '(' || trim(tni.tabname) || ')'"
X . " full_name,"
X . " 'I' partn_type,"
X . " tni.partnum partition," # partnum of index
X . " ph.lockid,"
X . " trim(ds.name) dbspace," # Name of dbspace hosting the partition
X . " ph.nrows," # Row count
X . " ph.nextns," # Number of extents
X . " (ph.pagesize/1024) pagesize," # Size of a page, in KB
X . " ph.nptotal," # How many pages allocated to partn?
X . " ph.npused" # How many pages are really occupied?
X . " from systabnames tni,"
X . " systabnames tnt, "
X . " sysptnhdr ph,"
X . " sysdbspaces ds"
X . " where ( ph.nkeys = 1" # This negates above OR condition
X . " and ph.partnum != ph.lockid)" # and identifies an index partition
X . " and tni.partnum = ph.partnum" # Partnum of index partition
X . " and tnt.partnum = ph.lockid" # Partnum of primary table
X . " and ph.dbsnum = ds.dbsnum"
X . " and ds.is_sbspace = 0" # Smart-dbspace have no place here either
X . " %DBSNAME%"
X . " %TABLE%"
X . " %PARTNUM%"
X . " %NOSYSTEM%"
X . " %INTOTEMP%"
X ;