Large object columns (BLOB, CLOB, DBCLOB) do not live in the base table space. Db2 stores each LOB in an auxiliary table in a LOB table space, linked from the base row by a ROWID. When that LOB space is damaged, or after a point-in-time recover that did not include every related space, the CHECK LOB utility is how you ask DB2 to walk the LOB pages and report structural defects and invalid LOB values.
Two different questions get two different utilities:
IBM documents these times to run CHECK LOB:
After a successful run, CHECK LOB resets CHKP and AUXW. Exception: SHRLEVEL CHANGE does not set CHKP or AUXW even if it finds inconsistencies—treat those messages as a report, then follow up with REPAIR, RECOVER, or a REFERENCE-level check.
You need STATS, DBADM/DBCTRL/DBMAINT on the database, System DBADM, SYSCTRL, SYSADM, or installation SYSOPR. Implicit databases can be authorized on the implicit database or DSNDB04. SHRLEVEL CHANGE also needs authority to run DFSMSdss ADRDSSU and RACF ALTER on the shadow data sets.
12345678//CHLOB EXEC DSNUPROC,SYSTEM=DB2A,UID='PAY.CHLOB' //SYSIN DD * CHECK LOB TABLESPACE PAYDB.PAYLOB1 SHRLEVEL REFERENCE EXCEPTIONS 0 SORTDEVT SYSDA SORTNUM 4 /*
Required DDs: SYSIN, SYSPRINT, UTPRINT. The LOB table space is named in SYSIN; it does not need its own DD. Sort work must not span volumes and must be disk, not tape. Allow about 1.2 times the data to be sorted.
| Phase | What happens |
|---|---|
| UTILINIT | Initialization |
| CHECKLOB | Scan active LOB pages; up to four records per LOB page |
| SORTIN / SORT / SORTOUT | Sort those records |
| REPRTLOB | Examine sorted records and issue error messages |
| UTILTERM | Cleanup |
| Option | Meaning |
|---|---|
| TABLESPACE db.lobts | LOB table space to check. Database defaults to DSNDB04. |
| CLONE | Check clone LOB data only, not the base table’s LOBs. |
| SHRLEVEL REFERENCE | Default. Readers OK; writers blocked on the object being checked. |
| SHRLEVEL CHANGE | Check DFSMSdss shadows while applications keep read-write. |
| EXCEPTIONS n | Stop in CHECKLOB after n message-reported defects. 0 = no limit. |
| PUNCHDDN dd | SHRLEVEL CHANGE: DD or TEMPLATE for generated REPAIR statements. Default SYSPUNCH. |
| SORTDEVT / SORTNUM | Dynamic sort work on disk. SORTNUM 2–255; ignored if IGNSORTN=YES. |
REFERENCE (default) lets applications read but not write the object being checked. That is the run that can clear CHKP/AUXW.
CHANGE drains writers, forces buffers to disk, copies the LOB space and its indexes to shadows with DFSMSdss, then checks the shadows while production returns to read-write. FlashCopy is preferred; if FlashCopy is unavailable, DFSMSdss falls back to a slower copy and the drain window grows. Set subsystem parameter CHECK_FASTREPLICATION to REQUIRED if you want the job to fail rather than crawl through a non-FlashCopy copy.
Every defect reported by a message counts toward EXCEPTIONS. When the count is reached, the utility ends in the CHECKLOB phase. With SHRLEVEL CHANGE, PUNCHDDN (default SYSPUNCH) receives REPAIR control statements that delete the LOBs named in those messages. After you apply those REPAIR statements, run CHECK DATA on the base table space so the corresponding LOB columns are marked invalid.
12345678CHECK LOB TABLESPACE PAYDB.PAYLOB1 CLONE SHRLEVEL CHANGE DRAIN_WAIT 20 RETRY 6 EXCEPTIONS 50 PUNCHDDN SYSPUNCH SORTDEVT SYSDA;
Recover a LOB table space that is in RECOVER-pending first. CHECK LOB no longer needs SYSUT1 and SORTOUT; WORKDDN is ignored so you do not have to edit old JCL. If the base and LOB are both damaged, RECOVER the set to a common point, then CHECK LOB, then CHECK DATA.
DISPLAY DATABASE shows CHKP and AUXW. Do not confuse AUXW (invalid LOB values, often still readable) with CHKP (structure not trusted). CHECK INDEX is a different utility for index keys versus table rows—it does not replace CHECK LOB.
The base table is a photo album with captions. The actual photographs live in a second box (the LOB table space), each tagged so the caption can find it. CHECK LOB opens that photo box and asks: are the photos torn, are the tags nonsense, is the box’s internal stacking broken? CHECK DATA later asks: does every caption still point at a real photo? CHKP is a sticker that says “this box might be smashed.” AUXW says “some photos look wrong.” A clean CHECK LOB peels those stickers off.
1. What does CHECK LOB inspect?
2. Which pending states does a successful CHECK LOB (SHRLEVEL REFERENCE) reset?
3. What does EXCEPTIONS 0 mean?
4. What is PUNCHDDN used for with SHRLEVEL CHANGE?
5. Must you recover a LOB space in RECP before CHECK LOB?