Db2 Tools for z/OS

 View Only

Db2 Administration Tool 13.1: Generating commands for a list of objects

By Kate Wheat posted Tue May 24, 2022 12:51 PM


One of the new usability features in Db2 Admin Tool 13.1 is the ability to generate commands for a list of objects in the Db2 catalog. In previous versions of Db2 Admin Tool, you had to execute a command individually on each object, which could be time consuming depending on the number of objects. This new feature eliminates these repetitive steps. For example, you can easily transfer ownership of a list of tables to another user in a single process without having to repeat steps.

You can generate any of the following commands with this new feature:

  • Any valid SQL statement (such as ALTER, DROP, TRUNCATE, GRANT, REVOKE, and TRANSFER OWNERSHIP)
  • DSN commands (such as BIND, REBIND, and FREE)
  • Db2 commands (such as ACCESS, START, and STOP)

You can generate these commands from any system catalog panel by using the new primary command GCMDS (Generate Commands). Then, you specify the command that you want to run by using a simple command-style syntax.

When you use GCMDS, you have the option to generate the commands as a batch job or store them in a data set. If you store the generated commands in a data set, you can import them into Change Management (CM) and analyze the changes to determine the impact on your objects. Note that only DDL statements can be imported.

The following scenario demonstrates how to change the buffer pool for a group of table spaces by using the new GCMDS command:

  1. Navigate to a catalog panel and ensure that only the objects on which you want to run the command are listed:
    1. From the main menu (ADB2), specify option 1 (DB2 System Catalog), and press Enter.
    2. On the System Catalog panel (ADB21), specify option S (Table spaces) and optionally any filtering criteria, and press Enter.
    3. On the Tables spaces panel (ADB21S), issue the SARG (Search Argument) command, and press Enter to filter the objects that are displayed.
    4. On the Search fields panel (ADB2SARG), specify filtering criteria, and press Enter.
      For this example, assume you want to change the buffer pool for only those table spaces whose names start with RDBK:
    5. Exit (PF3) back to panel ADB21S.

  2. On the ADB21S panel, specify the primary command GCMDS, and press Enter:

    Tip: You can specify GCMDS on any system catalog panel. The command that you generate will apply to all objects that are currently listed on that panel.

  3. On the Generate Commands panel (ADBGCMDS), specify whether you want to generate the commands in a data set (option 1) or in a job that you can run with the ADBTEP2 program (option 2) and optionally specify a data set name for the commands or job, and press Enter.

    This example specifies that the commands are to be stored in the TS6462.MYGCMDS.TSPACE data set:
  4. In the resulting ISPF edit session, add the statement or statements that you want to generate for all of the objects that were listed on the previous catalog panel. End each line with a semicolon ( ; ).

    This example changes the buffer pool for all of the listed table spaces:

    Tip: Write your statements for a single object and then replace the object schemas and names with supported variables.

    To view a list of accepted variables in the current context, issue the VARS command. For example, the following screen shows some of the variables that are valid for table spaces:

    Tip: Check the command syntax. The GCMDS feature does not validate Db2 syntax.

  5. Exit (PF3) the edit session. The data set or job is populated with the generated commands: