Object catalog tables are the DB2 for z/OS SYSIBM tables that describe databases, table spaces, tables, columns, indexes, keys, foreign keys, check constraints, and views. If you can join these twelve tables, you can inventory a schema, generate impact analysis, and check definitions without opening a modeling tool.
On z/OS, data is nested: database → table space → table → column. Indexes hang off tables. Constraints hang off tables. Views are named SELECTs that still appear as rows in SYSTABLES. Catalog queries follow that chain with creator and name columns—not with LUW's TABSCHEMA / TABNAME names.
123456789101112131415SELECT D.NAME AS DBNAME, S.NAME AS TSNAME, T.NAME AS TBNAME, T.TYPE, T.COLCOUNT FROM SYSIBM.SYSDATABASE D JOIN SYSIBM.SYSTABLESPACE S ON S.DBNAME = D.NAME JOIN SYSIBM.SYSTABLES T ON T.DBNAME = S.DBNAME AND T.TSNAME = S.NAME WHERE D.NAME = 'HRDB' AND T.TYPE = 'T' ORDER BY S.NAME, T.NAME WITH UR;
One row per database (the Db2 database object, not the whole subsystem). Key columns:
Use SYSDATABASE when you ask “which databases exist?” or “what STOGROUP does this database default to?” Table-level questions still need SYSTABLES.
One row per table space. NAME is unique only within DBNAME, so always qualify both. Useful columns include TYPE (partitioning organization), NPARTS / PARTITIONS, PGSIZE, BPOOL, DSSIZE, COMPRESS, and RUNSTATS fields such as SPACEF and NACTIVE. CLONE indicates whether a clone table exists in the space even when NTABLES still looks like one table—IBM documents that clone pairing explicitly.
TYPE values you will see in teaching material include blank for older simple spaces, O for classic partitioned, G for partition-by-growth, and R for partition-by-range. Confirm the value against your release’s SQL Reference when you automate DROP impact reports; do not guess new codes.
12345SELECT DBNAME, NAME, PARTITIONS, PGSIZE, BPOOL, COMPRESS FROM SYSIBM.SYSTABLESPACE WHERE DBNAME = 'HRDB' ORDER BY NAME WITH UR;
One row per table, view, alias, MQT, and several special table kinds. This is the usual starting point. NAME + CREATOR identify the object. DBNAME and TSNAME locate it. COLCOUNT, CREATEDTS, ALTEREDTS, STATSTIME, and REMARKS (COMMENT ON) round out the definition. CARD / CARDF and NPAGES are optimizer statistics, not a live row count.
| TYPE | Meaning |
|---|---|
| T | Base table |
| V | View |
| A | Alias |
| M | Materialized query table |
| G | Created global temporary table |
| H | History table (system-period temporal) |
| C | Clone table |
| R | Archive table |
| X | Auxiliary table (LOB) |
| P | Implicit table created for XML columns |
Aliases (TYPE A) still occupy a SYSTABLES row. IBM documents that alias rows typically show DBNAME DSNDB06 and TSNAME SYSTSTAB, with TBCREATOR, TBNAME, and LOCATION pointing at the base table or view (LOCATION filled for remote three-part names). Never assume TYPE = 'T' when you meant “anything named EMPLOYEE.”
12345SELECT NAME, TYPE, DBNAME, TSNAME, COLCOUNT, STATSTIME FROM SYSIBM.SYSTABLES WHERE CREATOR = 'HR' ORDER BY TYPE, NAME WITH UR;
One row for every column of every table and view. Join on TBCREATOR and TBNAME. COLNO is the 1-based ordinal. COLTYPE is a short type name (INTEGER, VARCHAR, DECIMAL, TIMESTMP, BLOB, XML, DISTINCT, and others listed in the SQL Reference). LENGTH and SCALE describe precision; for LOB and ROWID, IBM tells you to use LENGTH2 for the maximum data length because LENGTH is the base-table occupancy, not the LOB payload size.
123456SELECT COLNO, NAME, COLTYPE, LENGTH, SCALE, NULLS, DEFAULT FROM SYSIBM.SYSCOLUMNS WHERE TBCREATOR = 'DSN8D10' AND TBNAME = 'DEPT' ORDER BY COLNO WITH UR;
SYSINDEXES has one row per index. NAME + CREATOR identify the index; TBNAME + TBCREATOR identify the table. CLUSTERING, COLCOUNT, NLEAF, NLEVELS, FIRSTKEYCARD, FULLKEYCARD, and CLUSTERRATIOF are the optimizer’s view of the B-tree after RUNSTATS.
| UNIQUERULE | Meaning |
|---|---|
| D | Duplicates allowed (non-unique index) |
| U | Unique index |
| P | Primary index |
| C | Unique constraint (catalog-documented unique-constraint index) |
SYSINDEXPART has one row per index partition (partition 0 appears for non-partitioned indexes in many reports). Join IXCREATOR / IXNAME to SYSINDEXES. Use it for per-part SPACE, cardinality, and limit-key style operational questions—not as a substitute for SYSKEYS when you only need column order.
12345SELECT I.NAME, I.UNIQUERULE, I.CLUSTERING, I.COLCOUNT, I.NLEVELS FROM SYSIBM.SYSINDEXES I WHERE I.TBCREATOR = 'HR' AND I.TBNAME = 'EMPLOYEE' WITH UR;
These two tables look similar and are not interchangeable.
12345678910111213141516171819-- Index key order SELECT K.COLSEQ, K.COLNAME, K.ORDERING FROM SYSIBM.SYSINDEXES I JOIN SYSIBM.SYSKEYS K ON K.IXCREATOR = I.CREATOR AND K.IXNAME = I.NAME WHERE I.TBCREATOR = 'HR' AND I.TBNAME = 'EMPLOYEE' AND I.NAME = 'XEMP1' ORDER BY K.COLSEQ WITH UR; -- Unique / primary constraint columns SELECT CONSTNAME, COLSEQ, COLNAME FROM SYSIBM.SYSKEYCOLUSE WHERE TBCREATOR = 'HR' AND TBNAME = 'EMPLOYEE' ORDER BY CONSTNAME, COLSEQ WITH UR;
SYSRELS is one row per referential constraint. CREATOR and TBNAME are the dependent (child) table. REFTBCREATOR and REFTBNAME are the parent. RELNAME is the constraint name. IXNAME identifies the index used to support the relationship.
| DELETERULE | ON DELETE |
|---|---|
| A | NO ACTION |
| C | CASCADE |
| N | SET NULL |
| R | RESTRICT |
SYSFOREIGNKEYS is one row per column of that foreign key. Join CREATOR, TBNAME, and RELNAME. COLSEQ is the order of columns in the constraint. Together the pair answers both “who points at DEPARTMENT?” and “which child columns form the key?”
1234567891011121314SELECT R.RELNAME, R.CREATOR, R.TBNAME AS CHILD, R.REFTBCREATOR, R.REFTBNAME AS PARENT, R.DELETERULE, F.COLSEQ, F.COLNAME FROM SYSIBM.SYSRELS R JOIN SYSIBM.SYSFOREIGNKEYS F ON F.CREATOR = R.CREATOR AND F.TBNAME = R.TBNAME AND F.RELNAME = R.RELNAME WHERE R.REFTBCREATOR = 'HR' AND R.REFTBNAME = 'DEPARTMENT' ORDER BY R.RELNAME, F.COLSEQ WITH UR;
One row per table check constraint. You get the constraint name, the table (TBOWNER / TBNAME in IBM column naming), and the search condition text (CHECKCONDITION). Related tables such as SYSCHECKDEP record which columns the constraint references—use them when a DROP COLUMN impact report must find checks, not only FKs.
12345SELECT TBOWNER, TBNAME, CHECKNAME, CHECKCONDITION FROM SYSIBM.SYSCHECKS WHERE TBOWNER = 'HR' AND TBNAME = 'EMPLOYEE' WITH UR;
SYSTABLES TYPE V tells you a view exists. SYSVIEWS holds the view definition—the SELECT text CREATE VIEW stored, plus attributes such as whether the view is marked valid. Check IBM’s column list for your release for STATEMENT versus TEXT and any companion SYSVIEWS_STMT table when the definition is long.
To see what a view depends on, do not stop here: SYSVIEWDEP (next catalog page on dependencies) lists base tables, views, and other objects the view uses. That is the impact-analysis join when someone wants to DROP a table that might be under a view.
12345SELECT T.CREATOR, T.NAME, T.TYPE FROM SYSIBM.SYSTABLES T WHERE T.CREATOR = 'HR' AND T.TYPE = 'V' WITH UR;
A practical “describe this table” script hits SYSTABLES, SYSCOLUMNS, SYSINDEXES+SYSKEYS, SYSRELS+SYSFOREIGNKEYS, SYSCHECKS, and SYSTABAUTH (authorization page). Run each SELECT with WITH UR. Do not SELECT * in scheduled jobs: catalog tables are wide, and statement or check-condition columns can be large.
Think of a school. SYSDATABASE is the school building. SYSTABLESPACE is a classroom. SYSTABLES is the class roster (is it a real class, a nickname, or a window looking into another class?). SYSCOLUMNS is the list of subjects on each desk. SYSINDEXES is the labeled index tabs in the grade book. SYSKEYS tells you the order of those tabs. SYSRELS is the rule “you cannot be in Chess Club unless you are in this homeroom.” SYSCHECKS is “you must wear a badge.” SYSVIEWS is a window that shows only some of the desks without copying the desks.
1. Which SYSTABLES TYPE value identifies a base table?
2. How do you list columns of HR.EMPLOYEE in order?
3. SYSRELS versus SYSFOREIGNKEYS — what is the split?
4. UNIQUERULE = 'P' on SYSINDEXES means:
5. Where is the SELECT text of a view stored?