Control Center Operations Guide for VSE


REORGANIZE TABLE

The Reorganize Table function is used to simplify your work for backup and restore, table reorganization, and saving table structure information. The function provides four options; see Figure 47.

You can choose one of the following options:

 

1 - GENERATE DDL
Generates from the database all of the DDL required to recreate the table and the objects it contains, including indexes, views, and grants. The DDL is placed in the punch queue for inspection, alteration, or later use.|See Figure 49.

2 - UNLOAD TABLE
Generates DDL (as in Option 1) and writes it to a VSAM file. Then, a DBSU UNLOAD TABLE step is executed that writes the table data to a SAM or tape file. If SAM is selected, the file is REPRO'd to a VSAM file for more permanent retention. The unloaded data and generated DDL can be used as the basis for a subsequent RELOAD TABLE (Option 4) job. The table is not dropped. An example of an UNLOAD TABLE job created to do this is in Figure 60.

3 - REORGANIZE TABLE
Results in a full table reorganization. A jobstream is created that generates the DDL, UNLOADS the table, DROPs, recreates, and RELOADS the TABLE. Error recovery logic is included. An example of a REORGANIZE TABLE job is in Figure 61.

4 - RELOAD TABLE
Submits a job to recreate and reload a table that has been unloaded by Option 2. This is basically a table recovery facility. An example of the job created to do this is in Figure 62.

Each of the options is discussed in detail below and is accompanied by a sample JCL stream created by the Table Utility.

Figure 47. Table Reorganization Screen

+--------------------------------------------------------------------------------+
|     mm/dd/yyyy                 CONTROL CENTER                         hh:mm:ss |
|*----------------------- TABLE REORGANIZATION UTILITY ------------------------* |
|| DATABASE  => SQLDBA____________                                             | |
|| CREATOR   => SQLDBA__                                                       | |
|| TABLE     => ACTIVITY__________                                             | |
|| FILE      => 1 (1-3)                                                        | |
|| OPTION    => 3 (1 GENERATE DDL                 2 UNLOAD TABLE)              | |
||                (3 REORGANIZE TABLE             4 RELOAD TABLE)              | |
|| ***********************     OPTIONAL PARAMETERS     *******************     | |
|| DATABASE  => __________________                                             | |
|| OWNER     => ________                                                       | |
|| DBSPACE   => __________________                                             | |
|| CREATOR   => ________                                                       | |
|| TABLE     => __________________                                             | |
||                                                                             | |
||                                                                             | |
|| REBIND PACKAGE => 1 (1=YES/2=NO)         UPDATE ALL STATISTICS => : 2 (1/2) | |
|| COMMITCOUNT    => __________             DATA CAPTURE          => : none    | |
||                                                                             | |
|| TLBL FILE-ID   => _________________                                         | |
|*------------------------------------------------------------------ SQC61 ----* |
|                                                                                |
|PRESS ENTER TO PROCESS                                                          |
|F1=HELP F3=EXIT                                                                 |
+--------------------------------------------------------------------------------+

The following is a summary of the various processing options:

  1. Generate DDL

    If the Generate DDL option is specified, the utility will generate the table create statement and all associated database objects, including indexes, views, and grants.

  2. Unload Table

    This option creates a backup copy of a table using the UNLOAD TABLE DBSU command. The DDL will also be generated for backup purposes. The table will not be dropped.

  3. Table Reorganization

    If only the source database and table (at the top of the menu) are specified (meaning that this is not a migration), the utility will perform a table reorganization by generating a job to:

    1. generate the DDL for recreating the table and its objects,
    2. unload the data to a VSAM file,
    3. copy the VSAM file to a SAM file,
    4. drop the table,
    5. recreate the table,
    6. reload the table,
    7. and generate the table objects, such as indexes, etc.

    When data and DDL are both generated for a reorganization, the program has DBA authority for copying all dependent objects within the database (including those of other users). Control Center will copy the data using UNLOAD TABLE, will DROP and CREATE the table, RELOAD TABLE to reload the data, and then recreate all dependent objects (indexes, views, and grants).

    The presence of optional parameters affects the ultimate type of reorganization selected. These are:

  4. Reload Table

    This option reloads a table from a previous backup made with the UNLOAD TABLE function. The unloaded table resulting from a reorganization function that failed can also be used as input to this option.

Reorganize Table Processing Flow

When you submit a table reorganization job, Control Center:

  1. Links and establishes communication to the target server.
  2. Connects as user SQLREORG.
  3. Verifies the availability of the new DBSPACE (if specified).
  4. Gathers system catalog information about the specified table and creates corresponding DDL statements in the DBSU command file:
    1. Table create statements
    2. Table comments
    3. Column comments
    4. Table reload statements
    5. Referential integrity constraints
    6. Unique column definitions
    7. Index create statements
    8. Table column grants
    9. Table grants
    10. View creates/grants/comments/labels
    11. Package rebind statements
  5. Unloads the table data to the specified disk or tape.
  6. Executes the SQLDBSU command file from the Database Services Utility to reorganize the table and rebind any dependent packages.

Special Processing Considerations:

  1. In order to retain hierarchical dependencies, Control Center issues all grants in the same chronological order in which they were originally issued.

  2. In order to grant authority to an object, the grantor must first connect as the user who originally issued the grant. Therefore, the program must gather database connect passwords for all grantors. If a grantor does not have a connect password, a temporary password is assigned and later removed.

  3. The database server does not remove grant information from the system catalogs when a user is removed from the SYSTEM.SYSUSERAUTH table. Consequently, the REORGANIZATION job may need to connect as a nonexistent user in order to re-establish a grant. If this situation occurs, Control Center temporarily grants connect authority to you and later revokes it.

  4. |Referential Integrity Considerations:

Table Reorganization Menu Required Parameters

To reach the Table Reorganization menu shown in Figure 47, choose Option 3 on the Table Utility main menu.

When the menu is displayed, the DATABASE, CREATOR and TABLE fields at the top of the menu will be filled in from the Table Utility main menu.

When you installed Control Center, you defined one to three SAM DDL files to hold generated DDL. Specify the number of the file you want to use in the FILE field. (1 selects the small file, 2 selects the medium file, 3 selects the large file.) The number also indicates what SAM data file to use if you have not entered a Tape File Name. You do not need to specify the file number if you choose Option 1 or 2, because the DDL is written to the punch queue instead of to a file.

Enter the number of the option you want to execute in the Option field.

Table Reorganization Menu Optional Parameters

Parameters below the "OPTIONAL PARAMETERS" line are not required.

DATABASE
The name of a different database into which the table is reloaded. Use of this parameter lets you migrate a table from one database to another. For example, you can migrate a table from a development database to a production database. Before you migrate the table, you may want to ensure that the two databases are compatible so that all reload statements execute successfully. When you use the optional DATABASE parameter, the table in the old database remains unchanged.

OWNER/DBSPACE
If used, these two parameters must be used as a pair; however, if you omit one of the two, Control Center provides a default value. They indicate that you want to specify a new DBSPACE for the table.

If the new CREATOR/TABLE option is used, a copy will be performed. If a new CREATOR/TABLE is not specified, the table will be moved from the current DBSPACE to the new DBSPACE.

CREATOR/TABLE
If used, these two parameters must be used as a pair; however, if you omit one of the two, Control Center provides a default value. They indicate that you want to specify a new TABLE name (and CREATOR) for the DDL and/or data from the old table. Use of this option pair will cause the source table to be copied, (when using options other than 1 - Generate DDL) with the source table remaining unchanged.
Note:The table view names and index names will not be changed, causing failure of the DDL CREATE statements if the original table CREATOR is the same as the new CREATOR.

REBIND PACKAGE
Once a table has been reloaded, the Table Utility rebinds all

PACKAGES that are dependent on that table. To bypass package rebind processing, specify 2 (NO). The default value is 1 (YES). This option is not valid when the OWNER name is changed.

UPDATE ALL STATISTICS
By default, UPDATE STATISTICS is done for a table during reload and during index create. Statistics (including the number of rows and number of unique values in a column) are, by default, gathered only for columns that appear as the first column in an index. To update the statistics for all the columns in all of your indexes, specify 1 (YES) for this parameter.
Note:To perform periodic statistics updates, use the Table Utility main menu Option 5, Update Statistics.

When this parameter is set to NO, the statistics are reset only for the first column in each index. When set to YES, the statistics are reset for all columns in all indexes. The statistics include such things as the number of rows in a table and the number of unique values in an index column. They are used by SQL to optimize retrievals. Since this is can be a lengthy and resource consuming process, it is recommended that you do not reset all of the statistics during normal work hours. If you are reloading a table, this is an optimal time to reset ALL of the statistics.

COMMITCOUNT
Used to specify the frequency of COMMITS during reload processing. Enter a number in the range 1 through 2,147,483,647 (without the commas) to cause a COMMIT WORK to be executed after that number of input rows has been reloaded.

TAPE FILE NAME (TLBL FILE-ID)
Used to specify that data should be unloaded to tape instead of disk. The tape file must have been defined by the WORK FILE LABEL DEFINITION tool Chapter 6, Work File Label Definition Tool. This field does not apply to DDL because DDL is always unloaded to disk.

DATA CAPTURE
Allows changing or adding the attribute to a table for DB2 Release 5.1 (or later) databases. The default is to use what is currently in the catalog for the table. The value "CHANGES" can be used to change the current value held in the catalog. This affects how much information is retained in the log when a table is changed.

After entering the desired parameters, press ENTER to proceed to the Table Reorganization Submit Screen.

Using the TABLE REORGANIZATION Option

The Table Reorganization option can be used in a variety of ways to achieve different goals. Each of the options is discussed in more detail.

Option 1 - GENERATE DDL

By reading the catalogs, this option generates the DDL necessary to recreate a table and all of its associated objects. DDL is written to the VSE/POWER punch queue in the form of DBSU commands and can be used, as is, to recreate the table. This option:

Figure 48 is an example of the jobstream produced by Control Center to generate DDL for the SQLDBA.ACTIVITY table.

Figure 48. Table Reorg Option 1 (Generate DDL) - Sample Jobstream

* $$ JOB JNM=GENDDL,CLASS=0,DISP=D,PRI=9                                 
* $$ LST CLASS=A,PRI=3                                                   
* $$ PUN PRI=3                                                           
// JOB TRAY2 GENERATE DDL FOR TABLE "SQLDBA"."ACTIVITY"                  
// OPTION LOG                                                            
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *      
* STEP0001 UNLOAD DDL                                                    
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *      
// DLBL SQMTPRM,'SQLMSTR.TABLE.PARMS',,VSAM,CAT=SQMCAT                   
// DLBL SQMDDL,'L.DB2710.EXAMPLE.ROUTINE',0,VSAM,                      X 
               RECORDS=001000,RECSIZE=80,DISP=(NEW,KEEP),CAT=SQMCAT      
// ASSGN SYS005,SYSRDR                                                   
// ASSGN SYS006,SYSPCH                                                   
// ASSGN SYS011,SYSLST                                                   
// EXEC SQB60,SIZE=AUTO                                                  
%%SQLDBA            SQLDBA  ACTIVITY          1 N                        
/*
/&
 

Option 2 - UNLOAD TABLE

This option generates the DDL necessary to recreate a table and writes it to a VSAM file. It then unloads the table to a SAM disk file (or a tape if a tape label was specified). The SAM data file is then REPRO'd to a VSAM-managed SAM file for more permanent retention. Data is unloaded in system-defined format; you must make sure that this data file is not altered prior to reloading the table. This option is essentially a table backup. Used in conjunction with a RELOAD TABLE (Option 4), it provides the capability to recover from application errors.

Figure 60 shows a jobstream generated by Control Center to unload the SQLDBA.ACTIVITY TABLE.

Option 3 - REORGANIZE TABLE

This is the most comprehensive option of the reorganization tool. It schedules a full table reorganization, including generating all related DDL and executing it. Depending on the optional parameters chosen, a table can be migrated to another DBSPACE or another owner, the table name can be changed, and the table can be moved to another database.

Figure 61 shows a jobstream generated by Control Center to reorganize the SQLDBA.ACTIVITY table.

Option 4 - RELOAD TABLE

This option generates a job to reload a table previously unloaded or reorganized using Control Center. The previously created DDL and data files are used to recreate the table in its entirety. This option is the recovery counterpart to the UNLOAD TABLE option, (Option 2), and is the method of recovering from an error during a reorganization reload step.

Figure 62 shows a jobstream generated by Control Center to reload the SQLDBA.ACTIVITY table.

Table Reorganization Submit Screen

Figure 49 shows the Table Reorganization Submit Screen.

Figure 49. Table Reorganization Submit Screen

+--------------------------------------------------------------------------------+
|     mm/dd/yyyy                 CONTROL CENTER                         hh:mm:ss |
|*-------------------- TABLE REORGANIZATION SUBMIT SCREEN ---------------------* |
||                                                                             | |
|| JOBNAME   => ________                CLASS     => A                         | |
||                                                                             | |
|| PRI       => 3                       DISP      => D (D,H,K,L)               | |
||                                                                             | |
|| FROM      => ________                LST CLASS => A                         | |
||                                                                             | |
|| DUETIME   => ____ (HHMM)             DUEDATE   => ______  (AABBYY)          | |
||                                                                             | |
|| DUEDAY    => __________________________________________                     | |
||                                                                             | |
||                                                                             | |
|| OTHER     => ____________________________________________________________   | |
||                                                                             | |
||                                                                             | |
||                                                                             | |
||                                                                             | |
||                                                                             | |
|*------------------------------------------------------------------ SQC62 ----* |
|                                                                                |
|PRESS ENTER TO PROCESS                                                          |
|ENTER F1=HELP F3=EXIT F12=CANCEL                                                |
+--------------------------------------------------------------------------------+

To reach this menu, press ENTER from the Control Center Table Reorganization menu.

Table Reorganization Job Submission Screen Parameters

On each of the job submission screens (Table Reorganization, Create Table, and Update Statistics), there are parameters that are required, that are "required" but have defaults, and some that are optional. The following parameter descriptions apply to ALL of the Table Utility job submission screens.

JOBNAME
Specifies the job name for the Table Reorganization job and its associated queue entries. The JOBNAME parameter is the only parameter that you must enter because there are default values for the other parameters that are required.

CLASS
Specifies the class or partition in which you want this job to run. This parameter is required; its default value is A.

PRI
Specifies the priority to be assigned to the job. Specify a number from 0 to 9 where 9 is the highest priority. This parameter is required; its default value is 3.

DISP
Specifies how the job is to be handled in the reader queue. DISPosition may be specified as:

This parameter is required; its default value is D.
Note:If you enter data for any of the Table Utility functions that cause job submission and the job fails, you can easily resubmit the job. However, this is not completely true when creating a table because you may have entered a lot of data to define the table. There is no way to "reload" that data entry menu, but, there is a way to recover.

If you use DISP=K, then the job is kept in the VSE/POWER queue after the job ends, whether it is successful or not. If it is not successful, you can edit the job, fix the problem, and resubmit the job. If you use DISP=K, be sure to delete the job from the queue when you are done.

FROM
Specifies the ID of the user being allowed to manipulate or retrieve the job. This parameter is required. It defaults to the CICS User ID, even though that is not displayed on the screen.

LST CLASS
Defines the class to be assigned to printed output. The value of this parameter is used on a VSE/POWER $$ LST card. Specify any letter of the alphabet, or any number 0 through 9. This parameter is required; its default value is A.

DUETIME
Specifies the job processing start time using HH for hour and MM for minute in 24-hour clock time (OPTIONAL).

DUEDATE
Specifies the date on which the job is to be run, using YY for the year. Depending on the format defined for your system, AA is the month and BB is the day, or AA is the day and BB is the month (OPTIONAL).

DUEDAY
Specifies the day(s) the job is to be scheduled. You can enter a day name or abbreviation such as MON for Monday, or a list of these separated by commas and enclosed in parentheses. You can enter the number of the month or a list of day numbers separated by commas and enclosed in parentheses, and can also specify DAILY to schedule the job every day of the year. Certain combinations of the date and time parameters specify repeated processing. The VSE/POWER Installation and Operations Guide manual explains the logic used to control repeated processing (OPTIONAL).

|If you schedule repetitive processing, you can cancel the job |whenever necessary by displaying the POWER READer queue and deleting the |job.

OTHER
The VSE/POWER * $$ JOB card offers many parameters that do not appear on the Table Utility job submission screens. Use this field to have Control Center include those parameters when the job is submitted (OPTIONAL).

After entering the desired submit parameters, press ENTER to submit the job to VSE/POWER. For more information on VSE/POWER jobs, see the VSE/POWER Installation and Operations Guide. After submitting any Table Utility job, control returns to the screen from which job submission was selected.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]