Running Db2 utilities on tables

You can use Db2 Admin Tool to run the LOAD, UNLOAD, and REORG UNLOAD EXTERNAL utilities on tables. Based on the options that you choose, Db2 Admin Tool generates utility statements for you. You can choose to either save these utility statements in a work statement list (WSL) or generate a batch utility job stream.

About this task

If you want to run a utility against a LISTDEF list of tables, see Running utilities on LISTDEF lists.

Procedure

To run Db2 utilities on tables:

  1. Select the tables on which you want to run the utility:
    1. On the DB2 Administration Menu (ADB2) panel, specify option 1, and press Enter.
    2. On the System Catalog (ADB21) panel, specify option T. Optionally specify any filtering criteria at the bottom of the panel, and press Enter.
    3. On the Tables, Views, and Aliases (ADB21T) panel, select one or more tables:
      • If you want to select one table, issue the UT line command next to the table name, and press Enter.
      • If you want to select more than one table, filter the list as needed, specify the UTIL primary command, and press Enter.
    The Tables Utilities (ADB2UT) panel is displayed:
    Figure 1. Tables Utilities (ADB2UT) panel
    DB2 Admin --------------------- DD1A Table Utilities -------------------- 10:07
    Option ===>                                                                    
                                                                                   
     Execute utility on                                      DB2 System: DD1A      
        table DSN8810.DEPT                                   DB2 SQL ID: ADM001     
                                                                                   
       UL  - Unload using UNLOAD utility                                           
       UX  - Unload using REORG UNLOAD EXTERNAL                                    
        L  - Load (with input created from U)                                      
       LX  - Load (with input created from UX or UL)                               
       LO  - Load (stand-alone, force review/modify options)                       
       LC  - Load with cross loader (force review/modify options)
                                                                                   
       BP - Change batch job parameters                                            
       TU - Specify Template Usage                                                 
                                                                                   
     Utility control options:                                                       
       Review/change options  . . . . . . YES  (Yes/No)                             
       Generate work statement list . . . NO   (Yes/No)                             
       Generate template statements . . . NO   (Yes/No)                              

    The LC option (the cross-loader function of the LOAD utility) is displayed only in the following situations:

    • The table does not contain XML columns.
    • The panel is displayed for only one table, not multiple tables.
    • The target table does not contain GENERATED ALWAYS columns.
  2. Optional: Specify the following options as needed:
    BP
    If you plan to generate a batch utility job stream and want to change the JOB statement or other system parameters, specify BP and press Enter. On the resulting Batch Job Utility Parameters (ADB2UPA) panel, specify the options that you want to change. Then, press PF3 to save your changes and return to the Tables Utilities (ADB2UT) panel.
    TU
    If you plan to use templates and want to specify which template to use for a given utility option, specify TU. Then, follow the instructions in Associating data set templates with keywords.
  3. In the Option field, specify a utility to run on the selected table. For example, specify UL to run the UNLOAD utility.
  4. Change any of the following control options, and press Enter:
    Review/change options
    Specify whether you want to review and change the utility options. If the value is NO, the default options for the selected utility are used.
    Generate work statement list
    Specify whether you want the utility control statements to be added to a work statement list (WSL). If the value is NO, an executable utility job stream is generated instead. If you specify LO as the utility, Generate work statement list must be NO.
    Generate template statements
    Specify whether you want templates to be used. If the value is YES, Db2 Admin Tool uses the active templates that are defined. (If you want to change these templates, specify the TU option.)

    Db2 Admin Tool does not generate any TSODELETE statements to delete any existing data sets for the template first. To ensure that any existing data sets are deleted, consider using one of the following techniques when you define the template:

    • Specify the data set name pattern as a GDG (generation data group) where the next data set in the sequence is generated (+1), and change the other common options so that the GDGLIMIT is 1. This setup causes the data sets in the group to roll off so that only one data set exists at any one time. For example, a data set pattern name might be specified as &db..&ts..&name..ic(+1).
    • Specify a DISP option of NEW, DELETE, DELETE for the data set, if appropriate.
  5. If the Specify Utility Options panel is displayed, specify any additional options, and press Enter.
    This panel is not displayed in the following situations:
    • If you specified LX
    • If you specified Review/change options = NO and did not specify LO

    You must specify the options according to the Db2 syntax rules for utilities. For additional information, restrictions, and recommendations on various utility options, see Db2 online utilities (Db2 12 for z/OS).

    Restriction: Start of changeFor LOAD, you cannot specify the DELIMTED option when character conversion is required.End of change

    Example of Specify Utility Options panel for LOAD:

    Figure 2. Specify Utility Options - LOAD (ADB2UTC) panel
    ADB2UTC n ------------- DD1A Specify Utility Options - LOAD ------------- 18:36
    Command ===>                                                                   
                                                                                   
    Execute utility on table ELACZ.TBTEST1                                         
      using the following options:                                                 
    
    Utility ID . . . . .                                                          
    Unloaded data  . . .                                                          
    Unloaded how?  . . . U          (U - Unload utility, R - Reorg utility)       
    Table/Col info . . .                                                          
    PREFORMAT  . . . . .            (Yes/No)                                      
    PRESORTED  . . . . .            (Yes/No)                                      
    PRESORT  . . . . . .            (Yes/No)                                      
    RESUME . . . . . . .            (Yes/No)                                      
      BACKOUT  . . . . . YES        (Yes/No)                                      
    SHRLEVEL . . . . . .            (N - None, R - Reference, C - Change)         
    REPLACE  . . . . . .            (Yes/No)                                      
      COPYDDN1 . . . . .            (Primary copy DD name)                        
      COPYDDN2 . . . . .            (Backup copy DD name)                         
      RECOVERYDDN1 . . .            (Remote primary copy DD name)                 
      RECOVERYDDN2 . . .            (Remote backup copy DD name)                  
                                                                                  
    STATISTICS . . . . .            (Yes/No)                                      
    STATISTICS . . . . .            (Yes/No)                                       
      TABLE schema . . .           >                                               
            name . . . .                     > (ALL or ? for table look up)        
      SAMPLE . . . . . .            (Percent to sample during RUNSTATS: 1-100)     
      USE PROFILE  . . .            (Yes/No)                                       
      COLUMN name  . . .                     > (ALL or ? for column look up)       
      COLGROUP name  . .                     > (? for column look up)              
        FREQVAL  . . . .            (Yes/No)                                       
          COUNT  . . . .            (1-65535)                                      
          OCCUR  . . . .            (M - Most, B - Both, L - Least)                
        HISTOGRAM  . . .            (Yes/No)                                       
          NUMQUANTILES .            (1-100, default 100)                           
      STATCLGMEMSRT  . .            (0-4096)                                       
      INDEX ALL  . . . .            (Yes/No)                                       
        HISTOGRAM  . . .            (Yes/No)                                       
          NUMCOLS  . . .            (1-64, default 1)                              
          NUMQUANTILES .            (1-100, default 100)        
      REPORT . . . . . .            (Yes/No)                                       
      UPDATE . . . . . .            (A - All, P - Accesspath, S - Space, N - None) 
      INVALIDATECACHE  .            (Yes/No)                                       
      HISTORY  . . . . .            (A - All, P - Accesspath, S - Space, N - None) 
      FORCEROLLUP  . . .            (Yes/No)                                       
    FLASHCOPY  . . . . .            (Y - Yes, N - No, C - Consistent)              
    KEEPDICTIONARY . . .            (Yes/No)                                       
    REUSE  . . . . . . .            (Yes/No)                                       
    LOG  . . . . . . . .            (Yes/No/NOC - NOCopypend)                      
    WORKDDN1 . . . . . .            (DD name for temporary work file 1)            
    WORKDDN2 . . . . . .            (DD name for temporary work file 2)            
    SORTKEYS . . . . . .            (Estimated no. of keys or Yes/No)              
    FLOAT  . . . . . . .            (S - S390, I - IEEE)                           
    NOSUBS . . . . . . .            (Yes/No)                                       
    ENFORCE  . . . . . .            (Yes/No)                                       
    NOCHECKPEND  . . . .            (Yes/No)                                       
    ERRDDN . . . . . . .            (DD name for error processing)                
    DISCARDDN  . . . . .            (DD name for discarded records)               
    DISCARDS . . . . . . 2          (0 to 2147483647)                             
    SORTDEVT . . . . . .            (Device type for sort work files)             
    SORTNUM  . . . . . .            (Number of sort work files)                   
    SORTWK . . . . . . .            (0-4)                                         
    IGNORE . . . . . . .            (WHEN, PART, CONV, VALPROC, IDERROR, DUPKEY)  
    OVERRIDE                                                                      
      SYSTEMPERIOD . . .            (Yes/No)                                      
      IDENTITY . . . . .            (Yes/No)                                      
      TRANSID  . . . . .            (Yes/No)                                      
      NONDETERMINISTIC .            (Yes/No)                                      
      ROWCHANGE  . . . .            (Yes/No)                                      
    DRAIN_WAIT . . . . .            (0-1800)                                      
    RETRY  . . . . . . .            (0-255)                                       
    RETRY_DELAY  . . . .            (1-1800)                                  
    SWITCHTIME . . . . .                     (NONE, timestamp, CD, CT)         
      WITH TIME ZONE . .            (Yes/No)                                   
      YEARS  . . . . . .            (-99 - +99)                                
      MONTHS . . . . . .            (-99 - +99)                                
      DAYS . . . . . . .            (-99 - +99)                                
      HOURS  . . . . . .            (-99 - +99)                                
      MINUTES  . . . . .            (-99 - +99)                                
      SECONDS  . . . . .            (-99 - +99)                                
      MICROSECONDS . . .            (-999999 - +999999)                        
    INDEXDEFER . . . . .            (A - ALL, N - NPI, NO - NONE)              
      NONUNIQUE  . . . .            (Yes/No)                                   
    RBALRSN_CONVERSION .            (N - None, E - Extended)                   
    DECFLOAT ROUNDING  .            (Ceiling, Down, Floor, HalfDown, HalfEven, 
                                     HalfUp, Up)                               
    IMPLICIT_TZ  . . . .            (+/-hh:mm)                                 
    UPDMAXASSIGNEDVAL  .            (Yes/No)
    FORCE  . . . . . . .            (N - NONE, R - READERS, A - ALL) 
    DEFINEAUX  . . . . .            (Yes/No)      
    
  6. If you requested a work statement list (WSL): On the Specify Work Statement List (ADB2WLDA) panel, specify the WSL information, and press Enter.
    The utility statements are added to the WSL.
  7. If you requested a batch job stream: On the ISPF edit session, change the generated job as needed or copy it to another it to another data set.

    You can use standard ISPF editor commands to manually modify the JCL.

    The following figure shows an example of the generated JCL. In this example, the UX option (UNLOAD using REORG UNLOAD EXTERNAL) was chosen on the Tables Utilities (ADB2UT) panel.

    Figure 3. Edit generated JCL panel—UNLOAD utility (ADB2UE)
    -------------------------------------------------------------------------------
    EDIT       ISTJE.SPFTEMP2.CNTL                             Columns 00001 00072 
    Command ===>                                                  Scroll ===> PAGE 
    000016 //* STEP DELETE: DELETE OLD DATASETS                                    
    000017 //**********************************************************************
    000018 //DELETE  EXEC PGM=IEFBR14                                              
    000019 //SYSREC    DD DSN=ISTJE.DB2X.UNLD.DEPT,                                
    000020 //             UNIT=SYSDA,DISP=(MOD,DELETE,DELETE),SPACE=(TRK,1)        
    000021 //SYSPUNCH  DD DSN=ISTJE.DB2X.CNTL.DSN8D81A.DSN8S81D,                   
    000022 //             UNIT=SYSDA,DISP=(MOD,DELETE,DELETE),SPACE=(TRK,1)        
    000023 //*                                                                     
    000024 //**********************************************************************
    000025 //* STEP UNLOAD: UNLOAD TABLES                                          
    000026 //**********************************************************************
    000027 //UNLOAD       EXEC DSNUPROC,SYSTEM=DB2X,                               
    000028 //             LIB='SYS1.DSNDB2X.SDSNLOAD',                             
    000029 //             UID='ISTJE'                                              
    000030 //SYSPUNCH  DD DSN=ISTJE.DB2X.CNTL.DSN8D81A.DSN8S81D,                   
    000031 //             SPACE=(TRK,(5,5),RLSE),                                  
    000032 //             UNIT=SYSDA,                                              
    000033 //             DISP=(,CATLG,DELETE)                                     
    000034 //SYSREC    DD DSN=ISTJE.DB2X.UNLD.DEPT,                                
    000035 //             DISP=(,CATLG,DELETE),                                    
    000036 //             DCB=(BLKSIZE=8192),                                      
    000037 //             SPACE=(8192,(5,5),RLSE),                                 
    000038 //             UNIT=SYSDA                                               
    000039 //SYSIN     DD    *                                                     
    000040 UNLOAD TABLESPACE DSN8D81A.DSN8S81D                                     
    000041   FROM TABLE                                                            
    000042 "DSN8810"."DEPT"                                                        
    ****** **************************** Bottom of Data ****************************
    
  8. Make the following changes to the generated utility statements as needed:
    • If the utility statement unloads a table and might produce a record length that exceeds 32K, change the utility options so that the record length is less than 32K. (The record length might exceed 32K if the table has LOB objects.) Db2 Admin Tool requires that the record length be less than 32K when unloading tables.
    • If you specified UX and Generate work statement list = YES, add a TEMPLATE utility statement to the WSL. The generated REORG statement references a DD name but does not include a template for it.
  9. Submit the utility job or run the WSL.