Syntax and options of the REORG TABLESPACE control statement

The REORG TABLESPACE utility control statement, with its multiple options, defines the function that the utility job performs.

You can create a control statement with the ISPF/PDF edit function. After creating it, save it in a sequential or partitioned data set. When you create the JCL for running the job, use the SYSIN DD statement to specify the name of the data set that contains the utility control statement. Some of these options are not valid for LOB table spaces. For a list of those options, see Reorganization of a LOB table space.

Syntax diagram

>>-REORG--TABLESPACE-------------------------------------------->

                                           (1)                                     
>--+-LIST--listdef-name--+---------------+-------------------------------------+-->
   |                     +-PARALLEL--YES-+                                     |   
   |                     '-PARALLEL--NO--'                                     |   
   '-+----------------+-table-space-name-+-----------------------------------+-'   
     '-database-name.-'                  |       .-,---------------------.   |     
                                         |       V                       |   |     
                                         '-PART(---+-integer-----------+-+-)-'     
                                                   '-integer1:integer2-'           

                         .-SCOPE ALL-----.                  
>--+-------+--+-------+--+---------------+--+-----------+------->
   '-CLONE-'  '-REUSE-'  '-SCOPE PENDING-'  '-REBALANCE-'   

   .-LOG--YES-.  .-SORTDATA-----.                 
>--+----------+--+--------------+--+----------+----------------->
   '-LOG--NO--'  '-SORTDATA--NO-'  '-NOSYSREC-'   

                  .-AUTOESTSPACE YES-.   
>--| copy-spec |--+------------------+-------------------------->
                  '-AUTOESTSPACE NO--'   

   .-SHRLEVEL NONE----------------------------------------------------.   
>--+------------------------------------------------------------------+-->
   |                                  .-FASTSWITCH YES-.  .-AUX NO--. |   
   '-+-| SHRLEVEL-REFERENCE-spec |-+--+----------------+--+---------+-'   
     '-| SHRLEVEL-CHANGE-spec |----'  '-FASTSWITCH NO--'  '-AUX YES-'     

   .-FORCE--NONE----.                         
>--+----------------+--+------------------+--------------------->
   +-FORCE--READERS-+  +-SORTNPSI--AUTO---+   
   '-FORCE--ALL-----'  +-SORTNPSI--YES----+   
                       |              (2) |   
                       '-SORTNPSI--NO-----'   

>--+------------------------------------------------------------------+-->
   |              .-10------.              .-10------.                |   
   '-OFFPOSLIMIT--+---------+-INDREFLIMIT--+---------+-+------------+-'   
                  '-integer-'              '-integer-' '-REPORTONLY-'     

     .-UNLOAD--CONTINUE--.                                                  
>--+-+-------------------+--+----------------+--+---------------------+-+-->
   | |               (3) |  '-KEEPDICTIONARY-'  '-| statistics-spec |-' |   
   | '-UNLOAD--PAUSE-----'                                              |   
   +-UNLOAD--ONLY-------------------------------------------------------+   
   |                   .-NOPAD--NO------.                               |   
   '-UNLOAD--EXTERNAL--+----------------+--+-------------------------+--'   
                       |        .-YES-. |  | .---------------------. |      
                       '-NOPAD--+-----+-'  | V                     | |      
                                           '---| FROM-TABLE-spec |-+-'      

   .-PUNCHDDN--SYSPUNCH-.  .-DISCARDDN--SYSDISC-.   
>--+--------------------+--+--------------------+--------------->
   '-PUNCHDDN--ddname---'  '-DISCARDDN--ddname--'   

>--+------------------------------+----------------------------->
   '-| reorg tablespace options |-'   

>--+------------------------------------------------------+----><
   |                              .---------------------. |   
   |          .-NOPAD--NO------.  V                     | |   
   '-DISCARD--+----------------+----| FROM-TABLE-spec |-+-'   
              |        .-YES-. |                              
              '-NOPAD--+-----+-'                              

Notes:
  1. The default for PARALLEL is the value of the REORG_LIST_PROCESSING subsystem parameter.
  2. The default for SORTNPSI is the value of the REORG_PART_SORT_NPSI subsystem parameter.
  3. You cannot use UNLOAD PAUSE with the LIST option.

copy-spec:

Read syntax diagram
                      (1) (2)                 
   .-COPYDDN(SYSCOPY)---------------------.   
>>-+--------------------------------------+--------------------->
   '-COPYDDN(-+-ddname1--+----------+-+-)-'   
              |          '-,ddname2-' |       
              '-,ddname2--------------'       

>--+------------------------------------+----------------------->
   '-RECOVERYDDN(ddname3-+----------+-)-'   
                         '-,ddname4-'       

   .-FLASHCOPY--NO-------------------------------------------------.   
>--+---------------------------------------------------------------+-><
   '-FLASHCOPY--+-YES--------+--+--------------------------------+-'   
                '-CONSISTENT-'  '-FCCOPYDDN--(--template-name--)-'     

Notes:
  1. COPYDDN(SYSCOPY) is not the default if you specify SHRLEVEL NONE, and no partitions are in REORG-pending status.
  2. Either COPYDDN or FCCOPYDDN can be specified, or they can both be specified. At least one of these options must be specified for SHRLEVEL NONE when a partition is in REORG-pending status, or for SHRLEVEL CHANGE OR SHRLEVEL REFERENCE. If you specify FCCOPYDDN, but do not specify COPYDDN or a SYSCOPY DD statement or TEMPLATE specification, for SYSCOPY, only a FlashCopy® image copy is taken.

SHRLEVEL-REFERENCE-spec:

Read syntax diagram
>>-SHRLEVEL REFERENCE--| deadline-spec |--| drain-spec |--+---------------------+-><
                                                          |                 (1) |   
                                                          '-| change-spec |-----'   

Notes:
  1. For SHRLEVEL REFERENCE, the change-spec options are ignored. The exception is a partition-level REORG operation on a partitioned table space that has a non-partitioned index. In that case, the change-spec options are not ignored.

SHRLEVEL-CHANGE-spec:

Read syntax diagram
>>-SHRLEVEL CHANGE--| deadline-spec |--| drain-spec |--| change-spec |--| table-change-spec |-><

deadline-spec:

Read syntax diagram
   .-DEADLINE--NONE--------------------------------.   
>>-+-----------------------------------------------+-----------><
   '-DEADLINE--+-timestamp-----------------------+-'   
               '-| labeled-duration-expression |-'     

drain-spec:

Read syntax diagram
                           (1)                     (2)   
>>-+---------------------+------+----------------+-------------->
   '-DRAIN_WAIT--integer-'      '-RETRY--integer-'       

                            (3)  .-TIMEOUT--TERM--.   
>--+----------------------+------+----------------+------------><
   '-RETRY_DELAY--integer-'      '-TIMEOUT--ABEND-'   

Notes:
  1. The default for DRAIN_WAIT is the value of the IRLMRWT subsystem parameter.
  2. The default for RETRY is the value of the UTIMOUT subsystem parameter.
  3. The default for RETRY_DELAY is the smaller of the following two values: DRAIN_WAIT value × RETRY value, DRAIN_WAIT value × 10

Start of changechange-spec:End of change

Start of changeFor SHRLEVEL REFERENCE, the change-spec options are ignored. The exception is a partition-level REORG operation on a partitioned table space that has a non-partitioned index. In that case, the change-spec options are not ignored.End of change

             (1)                                
   .-MAXRO--------------.  .-DRAIN--WRITERS-.   
>>-+--------------------+--+----------------+------------------->
   '-MAXRO--+-integer-+-'  '-DRAIN--ALL-----'   
            '-DEFER---'                         

   .-LONGLOG--CONTINUE--.  .-DELAY--1200----.   
>--+--------------------+--+----------------+------------------><
   '-LONGLOG--+-TERM--+-'  '-DELAY--integer-'   
              '-DRAIN-'                         

Notes:
  1. The default for MAXRO is the RETRY_DELAY default value.

table-change-spec:

Read syntax diagram
>>-MAPPINGTABLE--table-name------------------------------------><

labeled-duration-expression:

Read syntax diagram
>>-+-CURRENT_DATE--------------------------+-------------------->
   '-CURRENT_TIMESTAMP--+----------------+-'   
                        '-WITH TIME ZONE-'     

   .-------------------------------------.   
   V                                     |   
>----+- + -+--constant--+-YEAR---------+-+---------------------><
     '- - -'            +-YEARS--------+     
                        +-MONTH--------+     
                        +-MONTHS-------+     
                        +-DAY----------+     
                        +-DAYS---------+     
                        +-HOUR---------+     
                        +-HOURS--------+     
                        +-MINUTE-------+     
                        +-MINUTES------+     
                        +-SECOND-------+     
                        +-SECONDS------+     
                        +-MICROSECOND--+     
                        '-MICROSECONDS-'     

statistics-spec:

>>-STATISTICS--+---------------------+--+---------------------+-->
               '-| stat-table-spec |-'  '-| stat-index-spec |-'   

   .-REPORT--NO--.  .-UPDATE--ALL------------.   
>--+-------------+--+------------------------+------------------>
   '-REPORT--YES-'  '-UPDATE--+-ACCESSPATH-+-'   
                              +-SPACE------+     
                              '-NONE-------'     

>--+-------------------------+--+----------------------+-------><
   '-HISTORY--+-ALL--------+-'  '-FORCEROLLUP--+-YES-+-'   
              +-ACCESSPATH-+                   '-NO--'     
              +-SPACE------+                               
              '-NONE-------'                               

stat-table-spec

Read syntax diagram
     .-TABLE--(--ALL--)-.                                      
>>-+-+------------------+--+-----------------+-------------+---><
   |                       '-SAMPLE--integer-'             |   
   | .---------------------------------------------------. |   
   | V                                                   | |   
   '---TABLE--(--table-name--)--+----------------------+-+-'   
                                '-| table-stats-spec |-'       

table-stats-spec:

Read syntax diagram
                        .-COLUMN--ALL-------------------.   
>>-+-----------------+--+-------------------------------+------><
   '-SAMPLE--integer-'  |            .-,-----------.    |   
                        |            V             |    |   
                        '-COLUMN--(----column-name-+--)-'   

Read syntax diagram
>>-+-------------------------+---------------------------------><
   '-FREQVAL--COUNT--integer-'   

stat-index-spec

Read syntax diagram
     .-INDEX--(--ALL--)-.                                        
>>-+-+------------------+--| correlation-stats-spec |--------+-><
   |           .-,--------------------------------------.    |   
   |           V                                        |    |   
   '-INDEX--(----index-name--| correlation-stats-spec |-+--)-'   

Start of changecorrelation-stats-spec:End of change

Read syntax diagram
             (1)     
   .-KEYCARD-----.   
>>-+-------------+---------------------------------------------->

   .-FREQVAL--NUMCOLS--1--COUNT--10----------------.   
>--+-----------------------------------------------+-----------><
   | .-------------------------------------------. |   
   | V                                           | |   
   '---FREQVAL--NUMCOLS--integer--COUNT--integer-+-'   

Notes:
  1. The KEYCARD option is deprecated. The KEYCARD functionality is now built into the default execution of the inline statistics for indexes and cannot be disabled.

FROM-TABLE-spec:

Read syntax diagram
>>-FROM--TABLE--table-name-------------------------------------->

>--+------------------------------------------+----------------><
   '-WHEN--(--| selection-condition-spec |--)-'   

selection-condition-spec:

Read syntax diagram
>>-+-| predicate |-------+-------------------------------------->
   '-selection condition-'   

   .--------------------------------------.   
   V                                      |   
>----+----------------------------------+-+--------------------><
     '-+-AND-+--+-| predicate |-------+-'     
       '-OR--'  '-selection condition-'       

predicate:

Read syntax diagram
>>-+-| basic predicate |---+-----------------------------------><
   +-| BETWEEN predicate |-+   
   +-| IN predicate |------+   
   +-| LIKE predicate |----+   
   '-| NULL predicate |----'   

basic predicate:

                         (1)   
>>-column-name--+- = --+---------------------------------------->
                +- <> -+       
                +- > --+       
                +- < --+       
                +- >= -+       
                '- <= -'       

>--+-constant------------------------+-------------------------><
   '-| labeled-duration-expression |-'   

Notes:
  1. The following forms of the comparison operators are also supported in basic and quantified predicates: !=, !<, and !>. For details, see comparison operators.

BETWEEN predicate:

Read syntax diagram
>>-column-name--+-----+--BETWEEN-------------------------------->
                '-NOT-'            

>--+-constant------------------------+--AND--------------------->
   '-| labeled-duration-expression |-'        

>--+-constant------------------------+-------------------------><
   '-| labeled-duration-expression |-'   

IN predicate:

Read syntax diagram
                               .-,--------.     
                               V          |     
>>-column-name--+-----+--IN--(---constant-+-)------------------><
                '-NOT-'                         

LIKE predicate:

Read syntax diagram
>>-column-name--+-----+--LIKE--string-constant------------------>
                '-NOT-'                          

>--+-------------------------+---------------------------------><
   '-ESCAPE--string-constant-'   

NULL predicate:

Read syntax diagram
>>-column-name--IS--+-----+--NULL------------------------------><
                    '-NOT-'         

reorg tablespace options:

Read syntax diagram
   .-UNLDDN--SYSREC-.                              
>>-+----------------+--+-----------------------+---------------->
   '-UNLDDN--ddname-'  '-SORTDEVT--device-type-'   

>--+------------------+--+-----------+-------------------------->
   '-SORTNUM--integer-'  '-PREFORMAT-'   

>--+--------------------+--------------------------------------><
   '-ROWFORMAT--+-BRF-+-'   
                '-RRF-'     

Option descriptions

TABLESPACE database-name.table-space-name
Specifies the table space (and, optionally, the database to which it belongs) that is to be reorganized.
If you reorganize a table space, its indexes are also reorganized.
database-name
Is the name of the database to which the table space belongs. The name cannot be DSNDB07.

The default value is DSNDB04.

table-space-name
Is the name of the table space that is to be reorganized. The name cannot be SYSUTILX if the specified database name is DSNDB01.
LIST listdef-name
Specifies the name of a previously defined LISTDEF list name. The utility allows one LIST keyword for each control statement of REORG TABLESPACE. The list must contain only table spaces.

Do not specify FROM TABLE, STATISTICS TABLE table-name, or STATISTICS INDEX index-name with REORG TABLESPACE LIST. If you want to collect inline statistics for a list of table spaces, specify STATISTICS TABLE (ALL). If you want to collect inline statistics for a list of indexes, specify STATISTICS INDEX (ALL). Do not specify PART with LIST.

REORG TABLESPACE is invoked once for each item in the list. This utility will only process clone data if the CLONE keyword is specified. The use of CLONED YES on the LISTDEF statement is not sufficient.

Start of changeThe partitions or partition ranges can be specified in a list.End of change

Start of changePARALLELEnd of change
Start of changeSpecifies whether REORG TABLESPACE LIST uses parallel or serial processing of partitions.
YES
Indicates that partitions are processed in parallel.
NO
Indicates that partitions are processed serially.

The default value is the value of the REORG_LIST_PROCESSING subsystem parameter.

End of change
CLONE
Indicates that REORG TABLESPACE is to reorganize only clone tables from the specified table spaces. This utility will only process clone data if the CLONE keyword is specified. The use of CLONED YES on the LISTDEF statement is not sufficient. Base tables in the specified table spaces are not reorganized. If you specify CLONE, you cannot specify STATISTICS. Statistics are not collected for clone tables.
REUSE
When used with SHRLEVEL NONE, specifies that REORG is to logically reset and reuse DB2®-managed data sets without deleting and redefining them. If you do not specify REUSE and SHRLEVEL NONE, DB2 deletes and redefines DB2-managed data sets to reset them.

If a data set has multiple extents, the extents are not released if you use the REUSE parameter.

REUSE does not apply if you also specify SHRLEVEL REFERENCE or CHANGE.

SCOPE
Indicates the scope of the reorganization of the specified table space or of one or more specified partitions.
ALL
Indicates that you want the specified table space or one or more partitions to be reorganized. The default is ALL.
PENDING
Start of changeIndicates that you want the specified table space or one or more partitions to be reorganized only if they are in REORG-pending (REORP, AREO*, or AREOR) status.End of change
PART(integer)
PART(integer1:integer2)
Start of changePART(integer,…integer,…integer1:integer2,…integer1:integer2)End of change
Start of changeIdentifies the set of partitions that are to be reorganized. The set of partitions must be enclosed in parentheses.

You can reorganize:

  • One or more single partitions
  • One or more ranges of partitions
  • A combination of one or more single partitions and one or more ranges of partitions

The partitions do not need to be consecutive.

Start of changeinteger, integer1, and integer2 are physical partition numbers. Each partition number must be in the range from 1 to the number of partitions that are defined for the table space or partitioning index. The maximum is 4096.End of change

integer
Designates a single partition.
integer1:integer2
Designates a range of existing table space partitions from integer1 through integer2.integer2 must be greater than integer1.

If you omit the PART keyword, the entire table space is reorganized.

If you specify the PART keyword for a LOB table space, DB2 issues an error message, and utility processing terminates with return code 8.

If you specify a partition range and the high or low partitions in the list are in a REORG-pending state, the adjacent partition that is outside the specified range must not be in REORG-pending state; otherwise, the utility terminates with an error.

Restriction: Start of changeYou cannot run concurrent REORG TABLESPACE SHRLEVEL CHANGE PART integer on the same table space with one or more non-partitioned indexes defined in it. Instead of submitting multiple jobs, you can merge the jobs into one job by specifying all the target partitions in the same REORG job.End of change
End of change
REBALANCE
Specifies that REORG TABLESPACE is to set new partition boundaries so that rows are evenly distributed across the reorganized partitions. If the columns that are used in defining the partition boundaries have many duplicate values within the data rows, even balancing is not always possible. Specify REBALANCE for more than one partition; if you specify a single partition for rebalancing, REORG TABLESPACE ignores the specification.

Start of changeYou can specify REBALANCE with SHRLEVEL NONE, SHRLEVEL CHANGE, or SHRLEVEL REFERENCE. You must specify SHRLEVEL REFERENCE if the base table space has an associated auxiliary LOB table space. In this case, you must also specify AUX YES, which is the default value if you specify REBALANCE. When REBALANCE is specified with SHRLEVEL REFERENCE, pending definition changes for conversion of a partitioned table space to a range-partitioned universal table space are not materialized.End of change

REBALANCE cannot be specified with SHRLEVEL CHANGE or SCOPE PENDING.

Restrictions: REBALANCE cannot be specified for the following objects:
  • Partition-by-growth table spaces
  • Base tables with XML columns
  • XML table spaces
  • An object that is involved in a clone relationship. (Because the base and clone tables share catalog information, REBALANCE can change the partition boundaries of the target table.)

When you specify REBALANCE, you must create an inline copy by performing one of the following actions:

  • Provide a SYSCOPY DD statement in the JCL.
  • Use the TEMPLATE utility to dynamically allocate the SYSCOPY data set.
  • Specify a DD name with the COPYDDN option in the REORG control statement and specify either a corresponding DD statement or TEMPLATE statement.

At completion, DB2 invalidates packages and the dynamic cache.

Start of changeLOGEnd of change
Start of changeSpecifies whether records are to be logged during the RELOAD phase of REORG SHRLEVEL NONE. If the records are not logged, the table space is recoverable only after an image copy is taken. An image copy is taken during the REORG execution if COPYDDN, FCCOPYDDN, RECOVERYDDN, SHRLEVEL REFERENCE, or SHRLEVEL CHANGE is specified.
YES
Specifies that log records are to be taken during the RELOAD phase. This option is not allowed for any table space in DSNDB01 or DSNDB06, or if the SHRLEVEL REFERENCE or CHANGE option is specified.

The default value is YES if SHRLEVEL NONE is specified explicitly or by default. If SHRLEVEL NONE is specified but the table space has the NOT LOGGED attribute, DB2 processes LOAD with LOG NO.

NO
Specifies that records are not to be logged. This option is the default and required if the SHRLEVEL REFERENCE or CHANGE option is specified. LOG NO puts the table space in COPY-pending status when REORG is executed remotely and RECOVERYDDN is not specified.
End of change
Start of changeSORTDATA or SORTDATA NOEnd of change
Start of changeSORTDATA specifies that the data is to be unloaded by a table space scan, and sorted in clustering order.

The default value is SORTDATA, unless you specify UNLOAD ONLY or UNLOAD EXTERNAL. If you specify one of these options, the default is SORTDATA NO.

SORTDATA NO specifies that the data is to be unloaded in the order of the clustering index. SORTDATA NO cannot be specified with SHRLEVEL CHANGE. Specify SORTDATA NO if one of the following conditions is true:

  • The data is in or near perfect clustering order, and the REORG utility is used to reclaim space from dropped tables.
  • The amount of data is very large, and an insufficient amount of disk space is available for sorting.

Start of changeFor a partitioned table space, REORG does not unload the records by way of the clustering index when the clustering index is not partitioning. The data records must be unloaded by partition order first. In addition, when REORG unload or reload partition parallelism is used, or when REORG is run on a partition-by-growth table space, REORG always performs a table space scan to unload the data records, when the clustering index is not used.End of change

Related information:
End of change
NOSYSREC
Start of changeSpecifies that REORG TABLESPACE is not to use an unload data set. The utility uses the output of sorting as the input to reload but does not use an unload data set for this process.

Omitting the unload data set can improve performance. However, when you omit the unload data set by specifying NOSYSREC, the following limitations exist for restarting the utility:

  • If an error occurs during reloading, you must restart the utility at the beginning of the UNLOAD phase. (If you do not specify NOSYSREC, you can start the utility at the RELOAD phase.)
  • If you specify SHRLEVEL NONE and an error occurs during reloading, you must first run the RECOVER utility with the most recent image copy.

If you specify SHRLEVEL NONE with NOSYSREC, create an image copy before you run REORG TABLESPACE.

Start of changeYou cannot specify NOSYSREC if any of the following conditions is true: End of change

  • No data will be sorted during the REORG TABLESPACE job. Examples: SORTDATA NO is specified, or no index is defined on the data that is being reorganized.
  • UNLOAD PAUSE is specified.
  • UNLOAD ONLY is specified.

For REORG TABLESPACE with the SHRLEVEL CHANGE and SORTDATA options, NOSYSREC is the default behavior.

End of change
COPYDDN (ddname1,ddname2)
Specifies the DD statements for the primary (ddname1) and backup (ddname2) copy data sets for the image copy.

ddname1 and ddname2 are the DD names.

The default value is SYSCOPY for the primary copy. A full image copy data set is created when REORG executes. This copy is called an inline copy. The table space does not remain in COPY-pending status regardless of which LOG option you specify.

Start of changeWhen an inline copy is performed, DB2 writes a record with ICTYPE='F' in the SYSIBM.SYSCOPY catalog table. The name of the inline copy data set is listed in that record. If an inline copy is performed when REORG is run on a range of partitions, DB2 writes a record with ICTYPE='F' for each partition. The inline copy data set name is the same in all of those records.End of change

If you specify SHRLEVEL NONE (explicitly or by default) for REORG, and COPYDDN is not specified, an image copy is not created at the local site.

COPYDDN(SYSCOPY) is assumed, and a DD statement for SYSCOPY is required if either of the following conditions are true:

  • You specify REORG SHRLEVEL REFERENCE or CHANGE, and you do not specify COPYDDN.
  • A table space or partition is in REORG-pending (REORP) status.
  • You specify REBALANCE.

The COPYDDN keyword specifies either a DD name or a TEMPLATE name specification from a previous TEMPLATE control statement. If utility processing detects that the specified name is both a DD name in the current job step and a TEMPLATE name, the utility uses the DD name.

REORG can take inline copies of XML table spaces.

RECOVERYDDN (ddname3,ddname4)
Specifies the DD statements for the primary (ddname3) and backup (ddname4) copy data sets for the image copy at the recovery site.

ddname3 and ddname4are the DD names.

You cannot have duplicate image copy data sets. The same rules apply for RECOVERYDDN as for COPYDDN.

The RECOVERYDDN keyword specifies either a DD name or a TEMPLATE name specification from a previous TEMPLATE control statement. If utility processing detects that the specified name is both a DD name in the current job step and a TEMPLATE name, the utility uses the DD name.

REORG SHRLEVEL REFERENCE of a LOB table space supports inline copies, but REORG SHRLEVEL NONE does not.

Start of changeFLASHCOPYEnd of change
Start of changeSpecifies whether FlashCopy technology is used to create a copy of the object. Valid values are YES, NO, or CONSISTENT. When FlashCopy is used, a separate data set is created for each partition or piece of the object.

The FlashCopy specifications on the utility control statement override any specifications for FlashCopy that are defined by using the DB2 subsystem parameters. If the FlashCopy subsystem parameters specify the use of FlashCopy as the default behavior of this utility, the FLASHCOPY option can be omitted from the utility control statement.

Important: If the input data set is less than one cylinder, FlashCopy technology might not be used for copying the objects regardless of the FLASHCOPY settings. The copy is performed by IDCAMS if FlashCopy is not used.
NO
Specifies that no FlashCopy is made. NO is the default value for FLASHCOPY.
YES
Specifies that FlashCopy technology is used to copy the object.

Specify YES only if the DB2 data sets are on FlashCopy Version 2 disk volumes.

Important: Start of changeUnder the following circumstances, the REORG TABLESPACE utility might not use FlashCopy even though YES is specified:
  • FlashCopy Version 2 disk volumes are not available
  • The source tracks are already the target of a FlashCopy operation
  • The target tracks are the source of a FlashCopy operation
  • The maximum number of relationships for the copy is exceeded

If FlashCopy is requested but not used, REORG TABLESPACE completes with return code 8. If no sequential inline copy is requested on the same job, the objects are left in COPY-pending status.

End of change
CONSISTENT
Specifies that FlashCopy technology is used to copy the object. Because the copies created by the REORG TABLESPACE utility are already consistent, the utility treats a specification of CONSISTENT the same as a specification of YES.
End of change
Start of changeFCCOPYDDNEnd of change
Start of changeSpecifies the template to be used to create the FlashCopy image copy data set names. If a value is not specified for FCCOPYDDN on the REORG TABLESPACE control statement when FlashCopy is used, the value specified on the FCCOPYDDN subsystem parameter determines the template to be used.
(template-name)
The data set names for the FlashCopy image copy are allocated according to the template specification. For table space or index space level FlashCopy image copies, because a data set is allocated for each partition or piece, ensure that the data set naming convention in the template specification is unique enough. Use the &DSNUM variable, which resolves to a partition number or piece number at execution time.
End of change
Start of changeAUTOESTSPACEEnd of change
Start of changeSpecifies that REORG automatically calculates and formats the size of the fixed hash space for hash-organized table spaces. The use of AUTOESTSPACE YES might reduce the number of rows in the overflow area.
YES
Specifies that DB2 uses real-time statistics (RTS) values to adjust the size of the hash space. User-specified HASH SPACE values stored in the SYSIBM.SYSTABLESPACE and SYSIBM.SYSTABLEPART catalog tables are not changed. YES is the default value for AUTOESTSPACE.
NO
Specifies that DB2 uses the HASH SPACE value specified for CREATE TABLE or ALTER TABLE. These values are stored in the SYSIBM.SYSTABLESPACE and SYSIBM.SYSTABLEPART catalog tables.
End of change
SHRLEVEL
Specifies the method that is to be used for the reorganization. The parameter that follows SHRLEVEL indicates the type of access that is to be allowed during the RELOAD phase of REORG.
NONE
Specifies that reorganization is to operate as follows:
  • Unloading from the area that is being reorganized (while applications can read but cannot write to the area)
  • Reloading into that area (while applications have no access), and then allowing read/write access again

If you specify NONE (explicitly or by default), you cannot specify the following parameters:

  • MAPPINGTABLE
  • MAXRO
  • LONGLOG
  • DELAY
  • DEADLINE
  • DRAIN_WAIT
  • RETRY
  • RETRY_DELAY
Restriction: Start of changeIf you specify UNLOAD PAUSE or UNLOAD ONLY, you cannot specify NOSYSREC. SHRLEVEL NONE cannot be specified for tables that are defined with ORGANIZE BY HASH.End of change

Start of changeWhen SHRLEVEL NONE is specified, pending definition changes are not materialized. End of change

Start of changeSHRLEVEL NONE of a LOB table space is allowed in DB2 10 conversion mode. However, a warning message is issued to indicate that this function is deprecated.End of change

REFERENCE
Specifies that reorganization is to operate as follows:
  • Unloading from the area that is being reorganized (while applications can read but cannot write to the area)
  • Reloading into a shadow copy of that area (while applications can read but cannot write to the original copy)
  • Switching the future access of an application from the original copy to the shadow copy by exchanging the names of the data sets, and then allowing read/write access again

Start of changeIf you specify SHRLEVEL REFERENCE and FASTSWITCH NO, pending definition changes are not materialized.End of change

If you specify REFERENCE for a LOB table space, you must take an inline copy during the reorganization.

If you specify REFERENCE, you cannot specify the following parameters:
  • LOG. Reorganization with REFERENCE always creates an image copy and always refrains from logging records during reloading.
  • Start of changeUNLOAD PAUSE, UNLOAD ONLY, or UNLOAD EXTERNAL. Reorganization with REFERENCE always uses UNLOAD CONTINUE, which is the default value. (You can explicitly specify UNLOAD CONTINUE or none of the UNLOAD options, but you cannot specify UNLOAD PAUSE, UNLOAD ONLY, or UNLOAD EXTERNAL.)End of change
  • MAPPINGTABLE.
Restriction: You cannot specify SHRLEVEL REFERENCE when REORG TABLESPACE with PART is run on a NOT LOGGED table space on which nonpartitioned indexes are defined.
CHANGE
Specifies that reorganization is to operate as follows:
  • Unloading from the area that is being reorganized (while applications can read and write to the area)
  • Reloading into a shadow copy of that area (while applications have read/write access to the original copy of the area)
  • Applying the log of the original copy to the shadow copy (while applications can read and usually write to the original copy)
  • Switching the future access of an application from the original copy to the shadow copy by exchanging the names of the data sets, and then allowing read/write access again

Start of changeIf you specify SHRLEVEL CHANGE and FASTSWITCH NO, pending definition changes are not materialized.End of change

If you specify CHANGE, you cannot specify the following parameters:

  • LOG. Reorganization with CHANGE always creates an image copy and always refrains from logging records during reloading.
  • Start of changeUNLOAD PAUSE, UNLOAD ONLY, or UNLOAD EXTERNAL. Reorganization with CHANGE always uses UNLOAD CONTINUE, which is the default value. (You can explicitly specify UNLOAD CONTINUE or none of the UNLOAD options, but you cannot specify UNLOAD PAUSE, UNLOAD ONLY, or UNLOAD EXTERNAL.)End of change

If you specify CHANGE, you must create a mapping table and specify the name of the mapping table with the MAPPINGTABLE option.

Restriction: Start of changeYou cannot specify SHRLEVEL CHANGE if the table space has the NOT LOGGED attribute, unless the table space is a LOB table space.End of change
DEADLINE
Specifies the deadline for the SWITCH phase to begin. If DB2 estimates that the SWITCH phase will not begin by the deadline, DB2 issues the messages that the DISPLAY UTILITY command would issue and then terminates the reorganization.

Start of changeThe final result and all the timestamp calculation of DEADLINE will be in TIMESTAMP(6).End of change

If REORG SHRLEVEL REFERENCE or SHRLEVEL CHANGE terminates because of a DEADLINE specification, DB2 issues message DSNU374I with reason code 2 but does not set a restrictive status.

NONE
Specifies that a deadline by which the SWITCH phase of log processing must begin does not exist.
timestamp
Specifies the deadline for the SWITCH phase of log processing to begin. This deadline must not have already occurred when REORG is executed.
labeled-duration-expression
Calculates the deadline for the SWITCH phase of log processing to begin. The calculation is based on either CURRENT TIMESTAMP or CURRENT DATE. You can add or subtract one or moreconstant value to specify the deadline. This deadline must not have already occurred when REORG is executed. CURRENT TIMESTAMP and CURRENT DATE are evaluated once, when the REORG statement is first processed. If a list of objects is specified, the same value will be in effect for all objects in the list.
CURRENT_DATE
Specifies that the deadline is to be calculated based on the CURRENT DATE.
CURRENT_TIMESTAMP
Specifies that the deadline is to be calculated based on the CURRENT TIMESTAMP.
Start of changeWITH TIME ZONEEnd of change
Start of changeSpecifies that the CURRENT TIMESTAMP is compared with the time zone column. The timestamp precision of the special register CURRENT TIMESTAMP should be the same as the column timestamp precision. Otherwise the default timestamp precision is used. The time zone of CURRENT TIMESTAMP is the value of special register CURRENT TIMEZONE. The comparison is done by comparing the UTC portion of the timestamp.End of change
constant
Indicates a unit of time and is followed by one of the seven duration keywords: YEARS, MONTHS, DAYS, HOURS, MINUTES, SECONDS, or MICROSECONDS. The singular form of these words is also acceptable: YEAR, MONTH, DAY, HOUR, MINUTE, SECOND, MICROSECOND.
DRAIN_WAIT integer
Specifies the number of seconds that the utility waits when draining the table space or index. The specified time is the aggregate time for objects that are to be reorganized. This value overrides the values that are specified by IRLMRWT and UTIMOUT. Valid values for integer are from 0 to 1800. If the keyword is omitted or if a value of 0 is specified, the utility uses the value of the lock timeout system parameter IRLMRWT.
RETRY integer
Specifies the maximum number of retries that REORG is to attempt. Valid values for integer are from 0 to 255.

Specifying RETRY can lead to increased processing costs and can result in multiple or extended periods of read-only access. For example, when you specify RETRY and SHRLEVEL CHANGE, the size of the copy that is taken by REORG might increase.

The default value is the value of the UTIMOUT subsystem parameter.

RETRY_DELAY integer
Specifies the minimum duration, in seconds, between retries. Valid values for integer are from 1 to 1800.

If you do not specify RETRY_DELAY, REORG TABLESPACE uses the smaller of the following two values:

  • DRAIN_WAIT value × RETRY value
  • DRAIN_WAIT value × 10
MAPPINGTABLE table-name
Specifies the name of the mapping table that REORG TABLESPACE is to use to map between the RIDs of data records in the original copy of the area and the corresponding RIDs in the shadow copy. This parameter is required if you specify SHRLEVEL CHANGE, and you must create a mapping table and an index for it before running REORG TABLESPACE. Enclose the table name in quotation marks if the name contains a blank.
MAXRO integer
Specifies the maximum amount of time for the last iteration of log processing. During that iteration, applications have read-only access. MAXRO is a log phase parameter. If MAXRO is specified when a log phase is not needed, an error message is issued.

The actual execution time of the last iteration might exceed the specified value for MAXRO.

The ALTER UTILITY command can change the value of MAXRO.

The default value is the RETRY_DELAY default value.

integer
integer is the number of seconds. Specifying a small positive value reduces the length of the period of read-only access, but it might increase the elapsed time for REORG to complete. If you specify a huge positive value, the second iteration of log processing is probably the last iteration.
DEFER
Specifies that the iterations of log processing with read-write access can continue indefinitely. REORG never begins the final iteration with read-only access, unless you change the MAXRO value with ALTER UTILITY.

If you specify DEFER, you should also specify LONGLOG CONTINUE.

If you specify DEFER, and DB2 determines that the actual time for an iteration and the estimated time for the next iteration are both less than 5 seconds, DB2 adds a 5 second pause to the next iteration. This pause reduces consumption of processor time. The first time this situation occurs for a given execution of REORG, DB2 sends message DSNU362I to the console. The message states that the number of log records that must be processed is small and that the pause occurs. To change the MAXRO value and thus cause REORG to finish, execute the ALTER UTILITY command. DB2 adds the pause whenever the situation occurs; however, DB2 sends the message only if 30 minutes have elapsed since the last message was sent for a given execution of REORG.

DRAIN
Specifies drain behavior at the end of the log phase after the MAXRO threshold is reached and when the last iteration of the log is to be applied. DRAIN is a log phase parameter. If DRAIN is specified when a log phase is not needed, an error message is issued.
WRITERS
Specifies the current default action, in which DB2 drains only the writers during the log phase after the MAXRO threshold is reached and subsequently issues DRAIN ALL on entering the switch phase.
ALL
Specifies that DB2 is to drain all readers and writers during the log phase, after the MAXRO threshold is reached.
Consider specifying DRAIN ALL if the following conditions are both true:
  • SQL update activity is high during the log phase.
  • The default behavior results in a large number of -911 SQL error messages.
LONGLOG
Specifies the action that DB2 is to perform, after sending a message to the console, if the number of records that the next iteration of logging is to process is not sufficiently lower than the number that the previous iterations processed. This situation means that the reading of the log by the REORG TABLESPACE utility is not being done at the same time as the writing of the application log.LONGLOG is a log phase parameter. If LONGLOG is specified when a log phase is not needed, an error message is issued.
CONTINUE
Specifies that until the time on the JOB statement expires, DB2 is to continue performing reorganization, including iterations of log processing, if the estimated time to perform an iteration exceeds the time that is specified for MAXRO.

A value of DEFER for MAXRO and a value of CONTINUE for LONGLOG together mean that REORG is to continue allowing access to the original copy of the area that is being reorganized and does not switch to the shadow copy. The user can execute the ALTER UTILITY command with a large value for MAXRO to initiate switching.

TERM
Specifies that DB2 is to terminate the reorganization after the delay that is specified by the DELAY parameter.
DRAIN
Specifies that DB2 is to drain the write claim class after the delay that is specified by the DELAY parameter. This action forces the final iteration of log processing to occur. DRAIN is a log phase parameter. If DRAIN is specified when a log phase is not needed, an error message is issued.
DELAY integer
Specifies the minimum interval between the time that REORG sends the LONGLOG message to the console and the time that REORG performs the action that is specified by the LONGLOG parameter. DELAY is a log phase parameter. If DELAY is specified when a log phase is not needed, an error message is issued.

integer is the number of seconds.

The default value is 1200.

TIMEOUT
Specifies the action that is to be taken if the REORG utility gets a timeout condition while trying to drain an object in either the log or switch phases.
TERM
Indicates that DB2 is to behave as follows if you specify the TERM option and a timeout condition occurs:
  1. DB2 issues an implicit TERM UTILITY command, causing the utility to end with a return code 8.
  2. DB2 issues the DSNU590I and DSNU170I messages.
  3. DB2 leaves the object in a read-write state.
Start of changeABENDEnd of change
Start of changeIndicates that, if a timeout condition occurs, DB2 takes one of the following actions:
  • If DRAIN ALL is specified, DB2 leaves the object in a UTRW state.
  • If DRAIN WRITERS is specified or used by default:
    • If the failure occurs when there is a write drain lock on the object, DB2 leaves the object in a UTRW state.
    • If the failure occurs when there is a read drain lock on the object, DB2 leaves the object in a UTRO state.
End of change
Start of changeFORCEEnd of change
Start of change Specifies the action to be taken when the utility is draining the table space.

When REORG FORCE is canceling the threads, it performs a soft cancel similar to the cancel that the CANCEL THREAD does.

NONE
Specifies that no action is taken when REORG performs drain. The REORG utility waits for the claimers to commit. The utility will timeout or restart when the drain fails, as determined by existing conditions.
READERS
Specifies that read claimers are canceled when REORG is requesting a drain all on the last RETRY processing.
ALL
Specifies that both read and write claimers are canceled when REORG is requesting a drain all or drain writers on the last RETRY processing.
End of change
Start of changeSORTNPSIEnd of change
Start of changeSpecifies when REORG TABLESPACE PART is to sort all keys of a non-partitioned secondary index. This keyword is ignored for a REORG that is not partition-level or a REORG without non-partitioned secondary indexes. If SORTNPSI is not specified, the value is determined by REORG_PART_SORT_NPSI subsystem parameter. The benefit of sorting all keys of a non-partitioned secondary index increases as the ratio of data that is reorganized to total data in the table space increases.

The default value is the value of subsystem parameter REORG_PART_SORT_NPSI.

AUTO
Specifies that if sorting all keys of the non-partitioned secondary indexes improves the elapsed time and CPU performance, all keys are sorted.
YES
Specifies that if sorting all keys of the non-partitioned secondary indexes improves the elapsed time, all keys are sorted.
NO
Specifies that only keys of the non-partitioned secondary indexes that are in the scope of the REORG are sorted.
End of change
Start of changeAUXEnd of change
Start of changeSpecifies that the LOB table spaces associated with the partitions of a partitioned table space being reorganized by the REORG utility are also reorganized.
NO
Indicates that a reorganization is performed on the base table space, but the associated LOB table spaces are not reorganized.

If the AUX keyword is omitted, AUX NO is the default unless one or more of the cases described in AUX YES are true.

Start of changeAUX NO is ignored when the target table space has pending definition changes to convert it from a simple or segmented table space to a partition-by-growth table space. In this case, AUX YES is in effect.End of change

YES
Indicates that LOB table spaces associated with the base partitioned table space are reorganized when the base table space is reorganized. Partitions of the associated table spaces are also reorganized.

If the AUX keyword is omitted, in the following cases, AUX YES is the default:

  • Start of changeREORG TABLESPACE of a partition-by-growth base table space with one or more LOB columns, where the table space has a MAXPARTITIONS value that is greater than one.End of change
  • Start of changeREORG TABLESPACE SHRLEVEL REFERENCE REBALANCE of a partitioned base table space with one or more LOB columns.End of change
  • Start of changeREORG TABLESPACE is run against directory table space SPT01, and SPT01 is in the REORP or AREOR state. In this case, AUX YES is always used.End of change
  • REORG TABLESPACE of a partitioned base table space with one or more LOB columns where one or more partition ranges are in REORG pending state because an ALTER TABLE PARTITION command has been issued to change the partition key boundaries.
  • REORG TABLESPACE DISCARD of a table in a partitioned table space with one or more LOB columns.

Start of changeWhen AUX YES is implicitly or explicitly specified, and the COPYDDN parameter specifies a TEMPLATE utility control statement with the &SN. or &TS. variables without substring notation on them, REORG takes the following actions for the LOB table spaces:End of change

Start of change
  • Creates inline image copies
  • Resets COPY-pending status
End of change

Start of changeWhen AUX YES is implicitly or explicitly specified and templates are specified, make sure that those templates generate unique data set names for the auxiliary table spaces that are being reorganized. Make sure that you account for auxiliary table spaces that are included in any specified LISTDEF lists.End of change

Start of changeWhen AUX YES is implicitly or explicitly specified, and FlashCopy image copies are taken as part of REORG, REORG produces image copies for all of the LOB table spaces that are being reorganized.End of change

Restrictions: Start of changeWhen REORG with AUX YES is run on a partition-by-growth table space with LOB columns, the following restrictions apply:
  • If REORG generates a new partition during the LOG phase, REORG cannot create inline image copies for LOB table spaces for the newly created partition. REORG leaves the LOB tables space in COPY-pending status and issues a warning message.
  • If you specify that REORG is to create inline copies and use a template for the copies, do not use the STACK YES option for the template. If you do so, REORG fails, because the base and auxiliary table spaces cannot be stacked on the same tape volume. If you need to use a template with the STACK YES option, specify AUX NO on the REORG statement and then reorganize and copy the auxiliary table spaces separately.
End of change
Recommendation: Start of changeAfter running REORG with AUX YES on a partition-by-growth table space with LOB columns, run COPY with SCOPE PENDING and a LISTDEF utility control statement that includes the LOB table spaces. Doing so creates a recovery base and removes COPY-pending status for the LOB table spaces.End of change
End of change
FASTSWITCH
Specifies which switch methodology is to be used for a given reorganization.
YES
Enables the SWITCH phase to use the FASTSWITCH methodology. This option is not allowed for the catalog (DSNDB06) or directory (DSNDB01).
NO
Causes the SWITCH phase to use IDCAMS RENAME.

Start of changeWhen FASTSWITCH NO is specified with SHRLEVEL REFERENCE or SHRLEVEL CHANGE, pending definition changes are not materialized.End of change

OFFPOSLIMIT integer
Indicates that the specified value is to be compared to the value that DB2 calculates for the explicit clustering indexes of every table in the specified partitions that are in SYSIBM.SYSINDEXPART. The calculation is computed as follows:
(NEAROFFPOSF + FAROFFPOSF) × 100 / CARDF 

Alternatively, DB2 checks the values in SYSINDEXPART for a single nonpartitioned table space, or for each partition if you specified an entire partitioned table space as the target object. If at least one calculated value exceeds the OFFPOSLIMIT value, REORG is performed or recommended. This option is valid for non-LOB table spaces only.

integer is the value that is to be compared and can range from 0 to 65535.

The default value is 10.

INDREFLIMIT integer
Indicates that the specified value is to be compared to the value that DB2 calculates for the specified partitions in SYSIBM.SYSTABLEPART for the specified table space. The calculation is computed as follows:
(NEARINDREF + FARINDREF) × 100 / CARDF

Alternatively, DB2 checks the values in SYSTABLEPART for a single nonpartitioned table space, or for each partition if you specified an entire partitioned table space as the target object. If at least one calculated value exceeds the calculated value exceeds the INDREFLIMIT value, REORG is performed or recommended. This option is valid for non-LOB table spaces only.

integer is the value that is to be compared and can range from 0 to 65535.

The default value is 10.

REPORTONLY
Specifies that REORG is only to be recommended, not performed. REORG produces a report with one of the following return codes:
1
No limit met; no REORG is to be performed or recommended.
2
REORG is to be performed or recommended.
UNLOAD
Specifies whether the utility job is to continue processing or end after the data is unloaded. Unless you specify UNLOAD EXTERNAL, data can be reloaded only into the same table and table space (as defined in the DB2 catalog) on the same subsystem. (This does not preclude VSAM redefinition during UNLOAD PAUSE.)

You must specify UNLOAD ONLY for the data set to be in a format that is compatible with the FORMAT UNLOAD option of LOAD. However, with LOAD, you can load the data only into the same object from which it is unloaded.

This option is valid for non-LOB table spaces only.

You must specify UNLOAD EXTERNAL for the data set to be in a format that is usable by LOAD without the FORMAT UNLOAD option. With UNLOAD EXTERNAL, you can load the data into any table with compatible columns in any table space on any DB2 subsystem.
CONTINUE
Specifies that, after the data has been unloaded, the utility is to continue processing. An edit routine can be called to decode a previously encoded data row if an index key requires extraction from that row.

If you specify DISCARD, rows are decompressed and edit routines are decoded. If you also specify DISCARD to a file, rows are decoded by field procedure, and the following columns are converted to DB2 external format:

  • SMALLINT
  • INTEGER
  • FLOAT
  • DECIMAL
  • TIME
  • TIMESTAMP

Otherwise, edit routines or field procedures are bypassed on both the UNLOAD and RELOAD phases for table spaces. Validation procedures are not invoked during either phase.

PAUSE
Specifies that, after the data has been unloaded, processing is to end. The utility stops and the RELOAD status is stored in SYSIBM.SYSUTIL so that processing can be restarted with RELOAD RESTART(PHASE).

This option is useful if you want to redefine data sets during reorganization. For example, with a user-defined data set, you can:

  • Run REORG with the UNLOAD PAUSE option.
  • Redefine the data set by using Access Method Services.
  • Restart REORG by resubmitting the previous job and specifying RESTART(PHASE).

However, you cannot use UNLOAD PAUSE if you specify the LIST option.

ONLY
Specifies that, after the data has been unloaded, the utility job ends and the status that corresponds to this utility ID is removed from SYSIBM.SYSUTIL.

If you specify UNLOAD ONLY with REORG TABLESPACE, any edit routine or field procedure is executed during record retrieval in the unload phase.

This option is not allowed for any table space in DSNDB01 or DSNDB06.

The DISCARD and WHEN options are not allowed with UNLOAD ONLY.

EXTERNAL
Specifies that, after the data has been unloaded, the utility job is to end and the status that corresponds to this utility ID is removed.

The UNLOAD utility has more functions. If you specify UNLOAD EXTERNAL with REORG TABLESPACE, rows are decompressed, edit routines are decoded, field procedures are decoded, and SMALLINT, INTEGER, FLOAT, DECIMAL, DATE, TIME, and TIMESTAMP columns are converted to DB2 external format. Validation procedures are not invoked.

Do not specify the EXTERNAL keyword for:
  • Table spaces in DSNDB01 or DSNDB06
  • Base tables with XML columns
  • XML table spaces

The DISCARD option is not allowed with UNLOAD EXTERNAL.

NOPAD

Start of changeSpecifies whether the variable-length columns in the unloaded or discarded records are to occupy the actual data length without additional padding. The unloaded records can have varying lengths. End of change

Start of change
YES
Specifies that the variable-length columns in the unloaded or discarded records are to occupy the actual data length without additional padding. YES is the default if NOPAD is specified without YES or NO.
NO
Specifies that REORG processing pads variable-length columns in the unloaded or discarded records to their maximum length; the unloaded or discarded records have equal lengths for each table. NO is the default if NOPAD is omitted.
End of change

You can specify the NOPAD option only with UNLOAD EXTERNAL or with UNLOAD DISCARD.

Although the LOAD utility processes records with variable-length columns that were unloaded or discarded with the NOPAD option, these records cannot be processed by applications that process only fields that are in fixed positions.

For the generated LOAD statement to provide a NULLIF condition for fields that are not in a fixed position, DB2 generates an input field definition with a name in the form of DSN_NULL_IND_nnnnn, where nnnnn is the number of the associated column.

For example, the LOAD statement that is generated for the EMP sample table looks similar to the LOAD statement that is in the following figure:

Figure 1. Sample LOAD statement generated by REORG TABLESPACE with the NOPAD keyword
LOAD DATA INDDN SYSREC   LOG NO  RESUME YES
 EBCDIC CCSID(00500,00000,00000)
 INTO TABLE "DSN8A10 "."EMP               "
 WHEN(00004:00005 = X'0012')
 ( "EMPNO             " POSITION(00007:00012) CHAR(006)
 , "FIRSTNME          " POSITION(00013)       VARCHAR
 , "MIDINIT           " POSITION(*)           CHAR(001)
 , "LASTNAME          " POSITION(*)           VARCHAR
 ,  DSN_NULL_IND_00005  POSITION(*)           CHAR(1)
 , "WORKDEPT          " POSITION(*)           CHAR(003)
                          NULLIF(DSN_NULL_IND_00005)=X'FF'
 ,  DSN_NULL_IND_00006  POSITION(*)           CHAR(1)
 , "PHONENO           " POSITION(*)           CHAR(004)
                          NULLIF(DSN_NULL_IND_00006)=X'FF'
 ,  DSN_NULL_IND_00007  POSITION(*)           CHAR(1)
 , "HIREDATE          " POSITION(*)           DATE EXTERNAL
                          NULLIF(DSN_NULL_IND_00007)=X'FF'
 ,  DSN_NULL_IND_00008  POSITION(*)           CHAR(1)
 , "JOB               " POSITION(*)           CHAR(008)
                          NULLIF(DSN_NULL_IND_00008)=X'FF'
 ,  DSN_NULL_IND_00009  POSITION(*)           CHAR(1) 
 , "EDLEVEL           " POSITION(*)           SMALLINT
                          NULLIF(DSN_NULL_IND_00009)=X'FF'
 ,  DSN_NULL_IND_00010  POSITION(*)           CHAR(1)
 , "SEX               " POSITION(*)           CHAR(001)
                          NULLIF(DSN_NULL_IND_00010)=X'FF'
 ,  DSN_NULL_IND_00011  POSITION(*)           CHAR(1)
 , "BIRTHDATE         " POSITION(*)           DATE EXTERNAL
                          NULLIF(DSN_NULL_IND_00011)=X'FF'
 ,  DSN_NULL_IND_00012  POSITION(*)           CHAR(1)
 , "SALARY            " POSITION(*)           DECIMAL
                          NULLIF(DSN_NULL_IND_00012)=X'FF'
 ,  DSN_NULL_IND_00013  POSITION(*)           CHAR(1)
 , "BONUS             " POSITION(*)           DECIMAL
                          NULLIF(DSN_NULL_IND_00013)=X'FF'
 ,  DSN_NULL_IND_00014  POSITION(*)           CHAR(1)
 , "COMM              " POSITION(*)           DECIMAL
                          NULLIF(DSN_NULL_IND_00014)=X'FF'
 )
FROM TABLE
Specifies the tables that are to be reorganized. The table space that is specified in REORG TABLESPACE can store more than one table. All tables that are specified by FROM TABLE statements must be unique. All tables are unloaded for UNLOAD EXTERNAL, and all tables might be subject to DISCARD. If you specify UNLOAD EXTERNAL and want to limit which tables and rows are unloaded, specify FROM TABLE with the WHEN option. If you specify DISCARD, you must qualify the rows that you want to discard by specifying FROM TABLE with the WHEN option.

Do not specify FROM TABLE with REORG TABLESPACE LIST.

table-name
Specifies the name of the table that is to be qualified by the following WHEN clause. The table must be described in the catalog and must not be a catalog table. If the table name is not qualified by a schema name, the authorization ID of the person who invokes the utility job step is used as the schema qualifier of the table name. Enclose the table name in quotation marks if the name contains a blank.
WHEN
Indicates which records in the table space are to be unloaded (for UNLOAD EXTERNAL) or discarded (for DISCARD). If you do not specify a WHEN clause for a table in the table space, all of the records are unloaded (for UNLOAD EXTERNAL), or none of the records is discarded (for DISCARD).

The option following WHEN describes the conditions for UNLOAD or DISCARD of records from a table and must be enclosed in parentheses.

selection condition
Specifies a condition that is true, false, or unknown about a specific row. When the condition is true, the row qualifies for UNLOAD or DISCARD. When the condition is false or unknown, the row does not qualify.

A selection condition consists of at least one predicate and any logical operators (AND, OR, NOT). The result of a selection condition is derived by applying the specified logical operators to the result of each specified predicate. If logical operators are not specified, the result of the selection condition is the result of the specified predicate.

Selection conditions within parentheses are evaluated first. If the order of evaluation is not specified by parentheses, AND is applied before OR.

If the control statement is in the same encoding scheme as the input data, you can code character constants in the control statement. Otherwise, if the control statement is not in the same encoding scheme as the input data, you must code the condition with hexadecimal constants.

If the target table is ASCII, any character constants must be specified in hexadecimal. For example, if the table space is in EBCDIC and the control statement is in UTF-8, use (1:1)=X'F1' in the condition rather than (1:1)='1'.

Restriction: REORG TABLESPACE cannot filter rows that contain encrypted data.
predicate
A predicate specifies a condition that is true, false, or unknown about a given row or group.
basic predicate
Specifies the comparison of a column with a constant. If the value of the column is null, the result of the predicate is unknown. Otherwise, the result of the predicate is true or false.
Predicate
Is true if and only if
column-name = constant
The column is equal to the constant or labeled duration expression.
column-name < > constant
The column is not equal to the constant or labeled duration expression.
column-name > constant
The column is greater than the constant or labeled duration expression.
column-name < constant
The column is less than the constant or labeled duration expression.
column-name > = constant
The column is greater than or equal to the constant or labeled duration expression.
column-name < = constant
The column is less than or equal to the constant or labeled duration expression.
Comparison operators: The following forms of the comparison operators are also supported in basic and quantified predicates: !=, !<, and !>, where ! means not. In addition, in code pages 437, 819, and 850, the forms ¬=, ¬<, and ¬> are supported. All these product-specific forms of the comparison operators are intended only to support existing REORG statements that use these operators and are not recommended for use in new REORG statements.

A not sign (¬), or the character that must be used in its place in certain countries, can cause parsing errors in statements that are passed from one DBMS to another. The problem occurs if the statement undergoes character conversion with certain combinations of source and target CCSIDs. To avoid this problem, substitute an equivalent operator for any operator that includes a not sign. For example, substitute '< >' for '¬=', '<=' for '¬>', and '>=' for '¬<'.

BETWEEN predicate
Indicates whether a given value is between two other given values that are specified in ascending order. Each of the predicate's two forms (BETWEEN and NOT BETWEEN) has an equivalent search condition, as shown in the following table. If relevant, the table also shows any equivalent predicates.
Table 1. BETWEEN predicates and their equivalent search conditions
Predicate Equivalent predicate Equivalent search condition
column BETWEEN value1 AND value2 None (column >= value1 AND column <= value2)
column NOT BETWEEN value1 AND value2 NOT(column BETWEEN value1 AND value2) (column < value1 OR column > value2)
Note: The values can be constants or labeled duration expressions.

For example, the following predicate is true for any row when salary is greater than or equal to 10 000 and less than or equal to 20 000:

SALARY BETWEEN 10000 AND 20000
labeled-duration-expression
Specifies an expression that begins with the following special register values:
  • CURRENT DATE (CURRENT_DATE is acceptable.)
  • CURRENT TIMESTAMP (CURRENT_TIMESTAMP is acceptable.)

Optionally, the expression contains the arithmetic operations of addition or subtraction, expressed by a number followed by one of the seven duration keywords:

  • YEARS (or YEAR)
  • MONTHS (or MONTH)
  • DAYS (or DAY)
  • HOURS (or HOUR)
  • MINUTES (or MINUTE)
  • SECONDS (or SECOND)
  • MICROSECONDS (or MICROSECOND)

Utilities evaluate a labeled-duration-expression as a timestamp and implicitly perform a conversion to a date if the comparison is with a date column.

Incrementing and decrementing CURRENT DATE: The result of adding a duration to a date, or of subtracting a duration from a date, is itself a date. (For the purposes of this operation, a month denotes the equivalent of a calendar page. Adding months to a date, then, is like turning the pages of a calendar, starting with the page on which the date appears.) The result must fall between the dates January 1, 0001 and December 31, 9999 inclusive.

The following table describes the effects of adding and subtracting years, months, days, and other dates.

Table 2. Effects of adding durations to and subtracting durations from CURRENT DATE
Value that is added or subtracted Effect
Years

Adding or subtracting a duration of years affects only the year portion of the date. The month is unchanged, as is the day unless the result would be February 29 of a non-leap-year. In this case, the day portion of the result is set to 28.

Months

Adding or subtracting a duration of months affects only months and, if necessary, years. The day portion of the date is unchanged unless that day does not exist in the resulting month. (September 31, for example). In this case the day is set to the last day of the month.

Adding a month to a date gives the same day one month later unless that day does not exist in the later month. In that case, the day in the result is set to the last day of the later month. For example, January 28 plus one month gives February 28; one month added to January 29, 30, or 31 results in either February 28 or, for a leap year, February 29. If one or more months is added to a given date and then the same number of months is subtracted from the result, the final date is not necessarily the same as the original date.

Days

Adding or subtracting a duration of days affects the day portion of the date, and potentially the month and year.

Dates

When a positive date duration is added to a date, or a negative date duration is subtracted from a date, the date is incremented by the specified number of years, months, and days.

When a positive date duration is subtracted from a date, or a negative date duration is added to a date, the date is decremented by the specified number of days, months, and years.

The order in which labeled date durations are added to and subtracted from dates can affect the results. When you add labeled date durations to a date, specify them in the order of YEARS + MONTHS + DAYS. When you subtract labeled date durations from a date, specify them in the order of DAYS - MONTHS - YEARS. For example, to add one year and one day to a date, specify the following code:

CURRENT DATE + 1 YEAR + 1 DAY

To subtract one year, one month, and one day from a date, specify the following code:

CURRENT DATE - 1 DAY - 1 MONTH - 1 YEAR
Incrementing and decrementing timestamps: The result of adding a duration to a timestamp, or of subtracting a duration from a timestamp, is itself a timestamp. Date and time arithmetic is performed as previously defined, except that an overflow or underflow of hours is carried into the date part of the result, which must be within the range of valid dates. For example, if the current date is January 15 and the current time is 20:00, CURRENT_TIMESTAMP+8 HOURS yields January 16, 04:00. Likewise, CURRENT_TIMESTAMP-22 HOURS yields January 14, 22:00.
IN predicate
Specifies that a value is to be compared with a set of values. In the IN predicate, the second operand is a set of one or more values that are specified by constants. Each of the predicate's two forms (IN and NOT IN) has an equivalent search condition, as shown in the following table.
Table 3. IN predicates and their equivalent search conditions
Predicate Equivalent search condition
value1 IN (value1, value2,…, valuen) (value1 = value2 OR … OR value1 = valuen)
value1 NOT IN (value1, value2,…, valuen) value1 ¬= value2 AND … AND value1 ¬= valuen)
Note: The values can be constants or labeled duration expressions.

For example, the following predicate is true for any row with an employee in department D11, B01, or C01:

WORKDEPT IN ('D11', 'B01', 'C01')
LIKE predicate
Qualifies strings that have a certain pattern. Specify the pattern by using a string in which the underscore and percent sign characters can be used as wildcard characters. The underscore character (_) represents a single, arbitrary character. The percent sign (%) represents a string of zero or more arbitrary characters.

In this description, let x denote the column that is to be tested and y denote the pattern in the string constant.

The following rules apply to predicates of the form "x LIKE y…". If NOT is specified, the result is reversed.
  • When x or y is null, the result of the predicate is unknown.
  • When y is empty and x is not empty, the result of the predicate is false.
  • When x is empty and y is not empty, the result of the predicate is false unless y consists only of one or more percent signs.
  • When x and y are both empty, the result of the predicate is true.
  • When x and y are both not null, the result of the predicate is true if x matches the pattern in y and false if x does not match the pattern in y.

The pattern string and the string that is to be tested must be of the same type; that is, both x and y must be character strings, or both x and y must be graphic strings. When x and y are graphic strings, a character is a DBCS character. When x and y are character strings and x is not mixed data, a character is an SBCS character, and y is interpreted as SBCS data regardless of is subtype.

Within the pattern, a percent sign (%) or underscore character (_) can represent the literal occurrence of a percent sign or underscore character. To have a literal meaning, each character must be preceded by an escape character.

The ESCAPE clause designates a single character. You can use that character, and only that character, multiple times within the pattern as an escape character. When the ESCAPE clause is omitted, no character serves as an escape character and percent signs and underscores in the pattern can only be used to represent arbitrary characters; they cannot represent their literal occurrences.

The following rules apply to the use of the ESCAPE clause:

  • The ESCAPE clause cannot be used if x is mixed data.
  • If x is a character string, the data type of the string constant must be character string. If x is a graphic string, the data type of the string constant must be graphic string. In both cases, the length of the string constant must be 1.
  • The pattern must not contain the escape character except when followed by the escape character, '%', or '_'. For example, if '+' is the escape character, any occurrences of '+' other than '++', '+_', or '+%' in the pattern is an error.
When that pattern does not include escape characters, a simple description of its meaning is:
  • The underscore character (_) represents a single, arbitrary character.
  • The percent sign (%) represents a string of zero or more arbitrary characters.
  • Any other character represents a single occurrence of itself.
Strings and patterns:

The string y is interpreted as a sequence of the minimum number of substring specifiers, such that each character of y is part of exactly one substring specifier. A substring specifier is an underscore, a percent sign, or any non-empty sequence of characters other than an underscore or percent sign.

The string x matches the pattern y if a partitioning of x into substrings exists, such that:

  • A substring of x is a sequence of zero or more contiguous characters, and each character of x is part of exactly one substring.
  • If the nth substring specifier is an underscore, the nth substring of x is any single character.
  • If the nth substring specifier is a percent sign, the nth substring of x is any sequence of zero or more characters.
  • If the nth substring specifier is neither an underscore nor a percent sign, the nth substring of x is equal to that substring specifier and has the same length as that substring specifier.
  • The number of substrings of x is the same as the number of substring specifiers.

When escape characters are present in the pattern string, an underscore, percent sign, or escape character represents a single occurrence of itself if and only if it is preceded by an odd number of successive escape characters.

Mixed-data patterns:

If x is mixed data, the pattern is assumed to be mixed data, and its special characters are interpreted as follows:

  • A single-byte underscore refers to one single-byte character; a double-byte underscore refers to one double-byte character.
  • A percent sign, either single-byte or double-byte, refers to any number of characters of any type, either single-byte or double-byte.
  • Redundant shift bytes in x or y are ignored.
NULL predicate
Specifies a test for null values.

If the value of the column is null, the result is true. If the value is not null, the result is false. If NOT is specified, the result is reversed.

KEEPDICTIONARY
Prevents REORG TABLESPACE from building a new compression dictionary when unloading the rows. The REORG utility builds the compression dictionary during the UNLOAD process. This dictionary is then used during the RELOAD phase to compress the data.

The efficiency of REORG increases with the KEEPDICTIONARY option for the following reasons:

  • The processing cost of building the compression dictionary is eliminated.
  • Existing compressed rows do not need to be compressed again.
  • Existing compressed rows do not need to be expanded, unless indexes require it or SORTDATA is used.

Possible reasons for not specifying KEEPDICTIONARY are:

  • If the data has changed significantly since the last dictionary was built, rebuilding the dictionary might save a significant amount of space.
  • Start of changeIf the current dictionary was built either by the LOAD utility or automatically by DB2 based on records that have been inserted over time, rebuilding the dictionary by using REORG might produce a better compression dictionary.End of change
  • If the data is being converted from basic row format to reordered row format, REORG builds a new dictionary for the new format. DB2 ignores the KEEPDICTIONARY option if the REORG utility changes the table space from basic row format to reordered row format.
  • Start of changeIf REORG is materializing a pending alter of the buffer pool, REORG builds a new dictionary. DB2 ignores the KEEPDICTIONARY option if REORG is materializing a buffer pool change.End of change

KEEPDICTIONARY is valid only if a compression dictionary exists and the table space or partition that is being reorganized has the COMPRESS YES attribute. If a dictionary does not exist, one is built, a warning message is issued, and all the records are compressed.

Messages DSNU234I and DSNU244I, which show compression statistics, are not issued when you specify REORG UNLOAD CONTINUE KEEPDICTIONARY or REORG UNLOAD PAUSE KEEPDICTIONARY.

REORG ignores the KEEPDICTIONARY option if a partition that is being reorganized is in REORG-pending status.

Note: You must use KEEPDICTIONARY to ensure that the compression dictionary is maintained.
STATISTICS
Specifies that statistics for the table space or associated index, or both, are to be gathered; the statistics are reported or stored in the DB2 catalog. If statistics are collected with the default options, only the statistics for the table space are updated.

If you specify a table space partition or a range of partitions along with the STATISTICS keyword, DB2 collects statistics only for the specified table space partitions. This option is valid for non-LOB table spaces only.

If you specify a base table space with the STATISTICS keyword, DB2 does not gather statistics for the related XML table space or its indexes.

Restrictions:
  • If you specify STATISTICS for encrypted data, DB2 might not provide useful statistics on this data.
  • You cannot specify STATISTICS if you specify the CLONE keyword.

Start of changeStatistics for both a table space and its associated indexes are collected and updated in the DB2 catalog when pending definition changes are materialized during REORG TABLESPACE with SHRLEVEL REFERENCE or CHANGE.End of change

Start of changeIf the STATISTICS keyword is specified in the REORG TABLESPACE statement, the options specified overwrite the default options.End of change

Start of changeIf the STATISTICS keyword is not specified in the REORG TABLESPACE statement, the following keywords are used by default:
  • STATISTICS TABLE ALL
  • INDEX ALL
  • UPDATE ALL
  • HISTORY ALL
End of change
Recommendation: Start of changePartition statistics can become obsolete. The partition statistics that can be obsolete are COLGROUP statistics, statistics for key column values in indexes, HISTOGRAM statistics, frequency statistics with NUMCOLS > 1, and statistics for extended indexes where applicable. Run the RUNSTATS utility to collect the partition statistics again.End of change

All tables identified by the STATISTICS TABLE keyword must belong to the table space that is specified in the TABLESPACE option.

TABLE
Specifies the table for which column information is to be gathered.

Do not specify STATISTICS TABLE table-name with the LIST keyword. Instead, specify STATISTICS TABLE (ALL).

(ALL)
Specifies that information is to be gathered for all columns of all tables in the table space.
(table-name)
Specifies the tables for which column information is to be gathered. If you omit the qualifier, the user identifier for the utility job is used. Enclose the table name in quotation marks if the name contains a blank.

If you specify more than one table, you must repeat the TABLE option. Multiple TABLE options must be specified entirely before or after any INDEX keyword that may also be specified. For example, the INDEX keyword may not be specified between any two TABLE keywords.

SAMPLE integer
Start of changeIndicates the percentage of rows to be sampled when collecting statistics on non-leading-indexed columns of an index or non-indexed columns. You can specify any value from 1 through 100.

The default value is 25. The SAMPLE option is not allowed for LOB table spaces.

End of change
COLUMN
Specifies columns for which column information is to be gathered.
You can specify this option only if you specify a particular table for which statistics are to be gathered (TABLE (table-name)). If you specify particular tables and do not specify the COLUMN option, the default, COLUMN(ALL), is used. If you do not specify a particular table when using the TABLE option, you cannot specify the COLUMN option; however, COLUMN(ALL) is assumed.
(ALL)
Specifies that statistics are to be gathered for all columns in the table.
(column-name, …)
Specifies the columns for which statistics are to be gathered.

You can specify a list of column names; the maximum is 10. If you specify more than one column, separate each name with a comma.

INDEX
Specifies indexes for which information is to be gathered. Column information is gathered for the first column of the index. All the indexes must be associated with the same table space, which must be the table space that is specified in the TABLESPACE option.

Do not specify STATISTICS INDEX index-name with the LIST keyword. Instead, specify STATISTICS INDEX (ALL).

(ALL)
Specifies that the column information is to be gathered for all indexes that are defined on tables that are contained in the table space.
(index-name)
Specifies the indexes for which information is to be gathered. Enclose the index name in quotation marks if the name contains a blank.
KEYCARD
Start of changeThe KEYCARD option is deprecated in the utility control statement and no longer needs to be specified to collect cardinality statistics on the values in the key columns of an index.

When the STATISTICS and INDEX options are specified, the utility always collects all of the distinct values in all of the 1 to n key column combinations in an index.n is the number of columns in the index. With the deprecation of KEYCARD, this functionality cannot be disabled.

The utility tolerates the specification of the KEYCARD option. The utility does not issue any messages if the control statement includes or excludes the KEYCARD option when STATISTICS and INDEX are specified.

End of change
FREQVAL
Controls the collection of frequent-value statistics.If you specify FREQVAL, it must be followed by the following additional keywords:
NUMCOLS
Indicates the number of key columns that are to be concatenated together when collecting frequent values from the specified index. Specifying '3' means that frequent values are to be collected on the concatenation of the first three key columns. The default value is 1, which means that DB2 collects frequent values on the first key column of the index.
COUNT
Indicates the number of frequent values that are to be collected. Specifying '15' means that DB2 collects 15 frequent values from the specified key columns. The default value is 10.
REPORT
Specifies whether a set of messages is to be generated to report the collected statistics.
NO
Indicates that the set of messages is not to be sent as output to SYSPRINT.
YES
Indicates that the set of messages is to be sent as output to SYSPRINT. The generated messages are dependent on the combination of keywords (such as TABLESPACE, INDEX, TABLE, and COLUMN) that are specified with the RUNSTATS utility. However, these messages are not dependent on the specification of the UPDATE option. REPORT YES always generates a report of SPACE and ACCESSPATH statistics.
UPDATE
Indicates whether the collected statistics are to be inserted into the catalog tables. UPDATE also allows you to select statistics that are used for access path selection or statistics that are used by database administrators.
ALL
Indicates that all collected statistics are to be updated in the catalog.
ACCESSPATH
Indicates that only the catalog table columns that provide statistics that are used for access path selection are to be updated.
SPACE
Indicates that only the catalog table columns that provide statistics to help database administrators assess the status of a particular table space or index are to be updated.
NONE
Indicates that no catalog tables are to be updated with the collected statistics. This option is valid only when REPORT YES is specified.
HISTORY
Specifies that all catalog table inserts or updates to the catalog history tables are to be recorded.

The default value is whatever value is specified in the STATISTICS HISTORY field on panel DSNTIP6.

ALL
Indicates that all collected statistics are to be updated in the catalog history tables.
ACCESSPATH
Indicates that only the catalog history table columns that provide statistics that are used for access path selection are to be updated.
SPACE
Indicates that only space-related catalog statistics are to be updated in catalog history tables.
NONE
Indicates that no catalog history tables are to be updated with the collected statistics.
FORCEROLLUP
Specifies whether aggregation or rollup of statistics is to take place when RUNSTATS is executed even if statistics have not been gathered on some partitions; for example, partitions have not had any data loaded. Aggregate statistics are used by the optimizer to select the best access path.
YES
Indicates that forced aggregation or rollup processing is to be done, even though some partitions might not contain data.
NO
Indicates that aggregation or rollup is to be done only if data is available for all partitions.
If data is not available for all partitions, DSNU623I message is issued if the installation value for STATISTICS ROLLUP on panel DSNTIP6 is set to NO.
PUNCHDDN ddname
Specifies the DD statement for a data set that is to receive the LOAD utility control statements that are generated by REORG TABLESPACE UNLOAD EXTERNAL or REORG TABLESPACE DISCARD FROM TABLE … WHEN.

ddname is the DD name.

The default value is SYSPUNCH.

PUNCHDDN is required if the limit key of the last partition of a partitioned table space has been reduced.

Start of changePUNCHDDN is not valid for LOB table spaces.End of change

The PUNCHDDN keyword specifies either a DD name or a TEMPLATE name specification from a previous TEMPLATE control statement. If utility processing detects that the specified name is both a DD name in the current job step and a TEMPLATE name, the utility uses the DD name.

DISCARDDN ddname
Specifies the DD statement for a discard data set, which contains copies of records that meet the DISCARD FROM TABLE … WHEN specification.

ddname is the DD name.

If you omit the DISCARDDN option, the utility saves discarded records only if a SYSDISC DD statement is in the JCL input.

The default value is SYSDISC.

The DISCARDDN keyword specifies either a DD name or a TEMPLATE name specification from a previous TEMPLATE control statement. If utility processing detects that the specified name is both a DD name in the current job step and a TEMPLATE name, the utility uses the DD name.

UNLDDN ddname
Specifies the name of the unload data set.

ddname is the DD name of the unload data set.

The default value is SYSREC.

The UNLDDN keyword specifies either a DD name or a TEMPLATE name specification from a previous TEMPLATE control statement. If utility processing detects that the specified name is both a DD name in the current job step and a TEMPLATE name, the utility uses the DD name.

SORTDEVT device-type
Specifies the device type for temporary data sets that are to be dynamically allocated by the external sort program.

device-type is the device type. You can specify any disk device that is acceptable to the DYNALLOC parameter of the SORT or OPTION control statement for the sort program. Start of change Tape devices are not supported by the sort program.End of change

If you omit SORTDEVT and require a sort of the index keys, you must provide the DD statements that the sort program needs for the temporary data sets.

SORTDEVT is ignored for the catalog and directory table spaces that are listed in Reorganizing the catalog and directory.

SORTDEVT cannot be used for LOB table spaces.

The utility does not allow a TEMPLATE specification to dynamically allocate sort work data sets. The SORTDEVT keyword controls dynamic allocation of these data sets.

SORTNUM integer
Specifies the number of temporary data sets that are to be dynamically allocated for all sorts that REORG performs.

integer is the number of temporary data sets that can range from 2 to 255.

Start of changeIf you omit SORTDEVT, SORTNUM is ignored. If you use SORTDEVT and omit SORTNUM, no value is passed to the sort program. The sort program uses its own SORTNUM default value.End of change

You need at least two sort work data sets for each sort. The SORTNUM value applies to each sort invocation in the utility. For example, a total of 24 sort work data sets would be allocated for a job, if the following criteria is true:

  • There are three indexes.
  • SORTKEYS is specified.
  • There are no constraints limiting parallelism.
  • SORTNUM is specified as 8.

Each sort work data set consumes both above the line and below the line virtual storage. Therefore, if you specify a value for SORTNUM that is too high, the utility might decrease the degree of parallelism due to virtual storage constraints, and possibly decrease the degree down to one, which would mean no parallelism.

Important: The SORTNUM keyword is ignored if the UTSORTAL subsystem parameter is set to YES and the IGNSORTN subsystem parameter is set to YES.

SORTNUM is ignored for the catalog and directory table spaces listed in Reorganizing the catalog and directory.

PREFORMAT
Start of changeSpecifies that the remaining pages are to be preformatted up to the high-allocated RBA in the table space and index spaces that are associated with the table space or partitions that are being reorganized. The preformatting occurs after the data is loaded and the indexes are built.

PREFORMAT can operate on an entire table space and its index spaces, or on a partition of a partitioned table space and its corresponding partitioning index space. When AUX YES is specified or accepted as the default, the LOB table spaces and auxiliary indexes that are associated with the base partitions that are being reorganized are also preformatted at the end of the RELOAD phase.

PREFORMAT is ignored if you specify UNLOAD ONLY or UNLOAD EXTERNAL.

End of change
ROWFORMAT
Specifies the output row format in the affected table space or partition. This keyword overrides the existing RRF subsystem parameter setting when the keyword is specified. This keyword has no effect on LOB, catalog, directory, XML table spaces, and Universal table spaces that are participating in a CLONE relationship.
BRF
Specifies that the table space or partition that is being reorganized or replaced are to be converted to or remain in basic row format.
RRF
Specifies that the table space or partition that is being reorganized or replaced are to be converted to or remain in reordered row format.
DISCARD
Start of changeSpecifies that records that meet the specified WHEN conditions are to be discarded during REORG TABLESPACE UNLOAD CONTINUE or UNLOAD PAUSE. If you specify DISCARDDN or a SYSDISC DD statement in the JCL, discarded records are saved in the associated data set. Otherwise, the utility discards records without saving them in a data set.

You can specify any SHRLEVEL option with DISCARD. However, if you specify SHRLEVEL CHANGE, modifications that are made during the reorganization to data rows that match the discard criteria are not permitted. In this case, REORG TABLESPACE terminates with an error.

If you specify DISCARD, rows are decompressed and edit routines are decoded. If you also specify DISCARD to a file, rows are decoded by field procedure, and the following columns are converted to DB2 external format:

  • SMALLINT
  • INTEGER
  • FLOAT
  • DECIMAL
  • TIME
  • TIMESTAMP

Otherwise, edit routines or field procedures are bypassed on both the UNLOAD and RELOAD phases for table spaces. Validation procedures are not invoked during either phase.

Restrictions: Do not specify DISCARD if any of the following conditions are true:
  • The REORG TABLESPACE statement includes the UNLOAD EXTERNAL or UNLOAD ONLY option.
  • The table space to be reorganized is any of the following objects:
    • A base table with XML columns
    • An XML table space
    • Start of changeA base table with LOB columns if the records to be discarded are more than 32 KB and you want to save them in a data set.End of change
    • Start of changeA system-period temporal table spaceEnd of change
End of change