Let's understand Mainframe
Home Tutorials Interview Q&A Quiz Mainframe Memes Contact us About us

Module 13: DB2 Utilities and Production Support


UNLOAD

The UNLOAD utility extracts rows from a DB2 table and writes them to a sequential data set. It is the reverse of LOAD. UNLOAD is used for data migration, creating test data, archiving, and sending data to systems that are not DB2.

What is UNLOAD

  • UNLOAD is a standalone DB2 utility that runs under DSNUTILB.
  • It reads the table space directly instead of going through SQL, so it is faster than a SELECT-based extract.
  • The output goes to the SYSREC data set in the format you specify.
  • You can unload a whole table, selected columns, selected rows with a WHEN clause, or a single partition.
  • UNLOAD does not lock the table for long and can run while the table is in use.

UNLOAD vs DSNTIAUL

  • UNLOAD is the modern utility with direct table space access and options like SPANNED for variable-length rows.
  • DSNTIAUL is an older sample program that runs under IKJEFT01 and unloads using SQL SELECT statements.
  • DSNTIAUL is simpler for quick ad-hoc extracts, but it is slower on large tables.
  • For production extracts and migrations, prefer the UNLOAD utility.

Common uses of UNLOAD

  • Migrating data from one DB2 subsystem to another (UNLOAD here, LOAD there).
  • Creating test data by unloading a slice of production rows.
  • Feeding data to data warehouses or non-mainframe platforms.
  • Archiving old rows before deleting them from the live table.

Example of an UNLOAD control statement:-

//UNLD01 EXEC PGM=DSNUTILB,PARM='DB2S,UNLD01' //STEPLIB DD DSN=DB2.V12.SDSNLOAD,DISP=SHR //SYSTSIN DD * UNLOAD DATA FROM TABLE HRDB.EMPLOYEE WHEN (SALARY > 50000) /* //SYSREC DD DSN=HRDB.OUTPUT.EMPDATA, // DISP=(NEW,CATLG,DELETE), // DCB=(LRECL=80,BLKSIZE=0,RECFM=FB), // SPACE=(CYL,(10,5)) //SYSPRINT DD SYSOUT=*






© copyright mainframebug.com
Privacy Policy
MainframeBug Assistant