After COPY, LOAD, UNLOAD, and RECOVER, a DB2 for z/OS shop still runs a dozen other utilities every week: REORG (FASTSWITCH, DISCARD, drain), RUNSTATS (COLGROUP, histograms, profiles), CHECK DATA/INDEX/LOB, MODIFY RECOVERY, QUIESCE, STOSPACE, CATMAINT, stand-alone DSNJU BSDS tools, and sample programs such as DSNTEP2 and DSNACCOX. This page is a guided survey of those tools so you know which job to reach for.
A full image copy is still the recovery base even when this page is not about COPY syntax. Concurrent copies (COPY CONCURRENT) use DFSMSdss to copy while the space remains available under documented page-size and CI rules. You cannot follow a concurrent copy with incremental COPY, MERGECOPY, or COPYTOCOPY. For day-to-day incrementals, use ordinary sequential COPY FULL NO instead.
Log application is the RECOVER (and REORG CHANGE) phase that reapplies Db2 log records after a restore or while a shadow is catching up. Image copies reduce how much log you must apply. System-level backups and FlashCopy-with-consistency add extra PRELOG / LOGCSR-style phases for uncommitted work—see the RECOVER utility page.
Online REORG (SHRLEVEL REFERENCE or CHANGE) builds shadow VSAM data sets. At SWITCH, FASTSWITCH YES updates the Db2 catalog (and ICF catalog instance) so the new data sets become current without a long copy-back. The old data sets remain as the previous instance until cleanup. FASTSWITCH NO is slower. IBM requires FASTSWITCH (not NO) to materialize pending DDL (pending ALTER). SHRLEVEL NONE does not use this shadow/switch model.
DISCARD FROM TABLE … WHERE on REORG TABLESPACE deletes rows that match the predicate while the space is reorganized. Discards go to a sequential data set (DISCARDDN). This is a bulk-delete technique with a reorg, not the LOAD discard file. Restrict the predicate; a wrong WHERE deletes production rows permanently.
STATISTICS on REORG, LOAD, or REBUILD collects catalog statistics during the utility so you can skip a separate RUNSTATS. Caution: REORG INDEX with inline statistics updates index statistics only. Table statistics can drift apart. Prefer a table-space RUNSTATS (or STATISTICS on REORG TABLESPACE) after index-only reorgs.
| Phase | Role |
|---|---|
| UNLOAD / RELOAD (or shadow build) | Rebuild clustering and free space; DISCARD can drop rows that match a predicate |
| LOG (SHRLEVEL CHANGE) | Apply log records of application changes that occurred during the REORG |
| Drain | Wait for claimers to release; then exclusive control for SWITCH |
| SWITCH | FASTSWITCH updates catalog to the new instance; old data sets become the previous instance |
Drain processing uses claim classes. Writers and readers must release claims before SWITCH. Tune DRAIN_WAIT, RETRY, and MAXRO so the last log iteration is short enough that drain succeeds in the batch window. If drain never completes, REORG fails and the original data sets remain current.
1234567REORG TABLESPACE HRDB.HRTS SHRLEVEL CHANGE FASTSWITCH YES DISCARD FROM TABLE HR.EMPLOYEE WHEN (TERM_DATE < CURRENT DATE - 7 YEARS) STATISTICS TABLE(ALL) INDEX(ALL) DRAIN_WAIT 30 RETRY 6
RUNSTATS writes summary information the optimizer reads at BIND and PREPARE. Column statistics describe one column. Distribution statistics (frequencies and histograms) describe how values clump. Correlation statistics (COLGROUP) describe columns used together.Key cardinality (FIRSTKEYCARD, FULLKEYCARD) describes index keys.
| Keyword | Meaning |
|---|---|
| Column statistics | COLCARD, HIGH2KEY, LOW2KEY, null counts per column in SYSCOLUMNS |
| COLGROUP | Cardinality of a set of columns that are used together in predicates |
| FREQVAL / frequency statistics | Most or least frequent values; COUNT n; NUMCOLS for index leading columns |
| HISTOGRAM / NUMQUANTILES | Equal-depth ranges (LOWVALUE/HIGHVALUE) for skewed or ranged predicates |
| Correlation / key cardinality | How columns and index keys relate; FIRSTKEYCARD, FULLKEYCARD, and COLGROUP CARD |
| TABLESAMPLE SYSTEM | Page-level sampling on UTS; faster than row SAMPLE on large spaces |
12345678910RUNSTATS TABLESPACE HRDB.HRTS TABLE(HR.EMPLOYEE) COLGROUP(WORKDEPT, JOB) FREQVAL COUNT 10 MOST HISTOGRAM NUMQUANTILES 20 INDEX(ALL) FREQVAL NUMCOLS 2 COUNT 10 TABLESAMPLE SYSTEM AUTO SHRLEVEL CHANGE UPDATE ALL
Referential integrity checks are CHECK DATA’s job: find child rows with no parent, or other constraint violations, and optionally copy or delete them (SCOPE, FOR EXCEPTION). After RECOVER to a point that is not a common QUIESCE across a table space set, CHECK-pending is expected until CHECK DATA runs.
Index consistency is CHECK INDEX: every index key must match a table row, and vice versa for the keys CHECK INDEX validates. Run it after suspected damage or after RECOVER of a table space without recovering COPY YES indexes to the same point.
XML consistency (and LOB consistency) use CHECK LOB and XML-related CHECK options so auxiliary/XML objects match the base table. CHECK LOB validates LOB table spaces; XML checks catch broken XML document structure versus node-ID indexes.
12345CHECK DATA TABLESPACE HRDB.HRTS SCOPE ALL FOR EXCEPTION IN HR.EMPLOYEE USE HR.EMP_EXC CHECK INDEX (HR.XEMP1) CHECK LOB TABLESPACE HRDB.HREMPAUX
MODIFY RECOVERY deletes rows from SYSIBM.SYSCOPY (and related SYSLGRNX) older than a DATE or AGE you specify. That is how you enforce retention periods: keep 14 days of copies, or keep two full-copy weekends, then delete. Deleting SYSCOPY rows does not always scratch the tape—your operations procedure must uncatalog or expire the data sets too.
Never MODIFY away the only full copy still required for recover-to-current. REPORT RECOVERY before and after. Recovery history that is gone cannot be used even if the tape is in the vault.
1234MODIFY RECOVERY TABLESPACE HRDB.HRTS DELETE AGE(*) * Prefer a real age, for example DELETE AGE(14), after you verify * REPORT RECOVERY still shows a usable full copy.
QUIESCE establishes a SYSCOPY ICTYPE Q log point. WRITE YES (typical) forces updated pages to disk so the quiesce point is a true external consistency point. That short write suspension is why QUIESCE can stall busy writers. WRITE NO records a log point without waiting for all writes—faster, weaker guarantee.
STOSPACE updates catalog space-use columns from the DB2 storage groups (how much space STOGROUP volumes actually hold). Space usage and storage statistics in SYSIBM.SYSINDEXPART / SYSTABLEPART SPACE values are not a substitute for RUNSTATS cardinality, but they help capacity planning.
CATMAINT performs catalog maintenance and catalog level migration: IBM’s jobs apply catalog changes when you activate a new function level or migrate a release. Do not invent CATMAINT SYSIN. Use the DSNTIJ* jobs in the Program Directory / Installation Guide.
The bootstrap data set (BSDS) is the inventory of active and archive logs, checkpoint queue, DDF records, and system-level backup history. Stand-alone DSNJU programs update or print it. They do not run under DSNUTILB.
| Program | Job |
|---|---|
| DSNJU003 | Change log inventory — add/delete active and archive logs, CRESTART, DDF, checkpoints |
| DSNJU004 | Print log map — report BSDS contents (logs, SLB history, CRCR) |
| DSNJU008 | Print CDDS (change-data-capture data set) contents |
| DSNJLOGF | Preformat active log data sets before first use |
Log inventory changes (NEWLOG, DELETE, STARTRBA/ENDRBA on archives) are DSNJU003. Many DSNJU003 updates require Db2 to be stopped; Db2 10+ -SET LOG NEWLOG and Db2 13 REMOVELOG cover some active-log changes while Db2 is up. Log print of BSDS contents is DSNJU004; printing actual log records is DSN1LOGP. Log archive of the active log to archive data sets is the -ARCHIVE LOG command (and offload), not a DSNJU program—DSNJU003 only records those archive data sets in the BSDS.
Current IBM Utility Guide chapters document DSNJU003, DSNJU004, and DSNJU008 (plus DSNJLOGF and DSNJCNVU). Load-module names such as DSNJU005 or DSNJU006 may appear in older outlines or local libraries; do not assume they are supported user utilities on Db2 12/13 without checking your SDSNLOAD and the Utility Guide for your release.
123456//MAP EXEC PGM=DSNJU004 //STEPLIB DD DISP=SHR,DSN=DSN.V12.SDSNLOAD //SYSUT1 DD DISP=SHR,DSN=DB2T.BSDS01 //SYSUT2 DD DISP=SHR,DSN=DB2T.BSDS02 //SYSPRINT DD SYSOUT=* //SYSIN DD DUMMY
1234567891011121314//TEP2 EXEC PGM=IKJEFT01,DYNAMNBR=20 //STEPLIB DD DISP=SHR,DSN=DSN.V12.SDSNEXIT // DD DISP=SHR,DSN=DSN.V12.SDSNLOAD //SYSTSPRT DD SYSOUT=* //SYSPRINT DD SYSOUT=* //SYSUDUMP DD SYSOUT=* //SYSTSIN DD * DSN SYSTEM(DB2T) RUN PROGRAM(DSNTEP2) PLAN(DSNTEP12) LIB('DSN.RUNLIB.LOAD') END /* //SYSIN DD * SELECT COUNT(*) FROM SYSIBM.SYSDUMMY1; /*
COPY takes photos. The utilities on this page are the rest of the school staff. REORG is the janitor who rearranges desks (FASTSWITCH is swapping the whole classroom for a cleaned one in one move; DISCARD throws away leftover lunch boxes). RUNSTATS is counting how many kids sit in each row so the teacher (optimizer) makes a smart seating plan. CHECK is the hall monitor verifying every kid has a matching name tag. MODIFY RECOVERY throws out old photo envelopes past the keep-by date. DSNJU003 is the office clerk who updates the list of diary books (logs). DSNTEP2 is a kid who can run errands (SQL) from a note. DSNACCOX is the nurse who looks at the attendance clipboard and says “this room needs a photo, a cleanup, or a head count.”
1. FASTSWITCH on REORG SHRLEVEL REFERENCE or CHANGE means:
2. COLGROUP with FREQVAL and HISTOGRAM on RUNSTATS collects:
3. MODIFY RECOVERY is used to:
4. DSNJU003 versus DSNJU004:
5. DSNTEP2 and DSNTIAUL are: