You can use the Generate Change Commands wizard, which can be invoked
repeatedly from the Deployment Script Editor, to generate the change commands
(the DDL, DCL, and DB2 commands, such as export, import, rebind, and runstats)
that are necessary to apply changes to a DB2 database.
Prerequisite: A deployment script for the database that you
plan to change must exist.
To generate change commands from the Deployment Script Editor, complete
the following tasks:
- Click the Change Commands tab to display
the Change Commands page.
- On the Change Commands page, click Generate Change Commands. The Generate Change Commands wizard starts.
Complete the steps
in the wizard to generate your commands. The wizard takes you through steps
to specify information for:
- Generating the DDL.
You must select Generate Delta DDL unless a delta
DDL file for the change has been created previously. You can also select Enable
Undo to generate the DDL that is required to undo the change. Both options
are checked by default; however, the last selection that you make in this
wizard is preserved. If you un-checked any of these options the last time
that you ran the wizard, they will not be checked when you return to the wizard.
Restriction: DB2® Change Management Expert might
not always generate rename statements in situations where a rename is possible.
However,
the delta DDL is fully editable and you can change any of the scripts manually.
You can replace the destructive changes with rename statements where it is
appropriate. You should use the Table Rename tab on
the first page of the Generate Change Commands wizard to specify what the
table has been renamed to and let the Delta DDL generator determine
if the rename is appropriate or not. The Change Command Editor will verify
that the script is syntactically correct. Check all of the generated commands
before you deploy them to your database.
Renaming a table. If you create a deployment script that
uses TEST as the base model, and then rename the ORG table to ORG_new in the
Test target database,
DB2 Change Management Expert records
this rename activity. When you generate your change commands by using the
Generate Change Commands wizard, the
Table Rename tab
displays the existing table name on the left side and the new table name that
you specified on the right side of the page. When you generate the change
commands, a RENAME statement similar to the one in the following example will
be generated:
RENAME SCHEMA.ORG TO "ORG_new"
If
you rename a table by using some method other than the deployment script,
you must specify the new table name on the Table Rename tab
of the Generate Change Commands wizard. For example, if you create a physical
model and rename the ORG table to ORG_new, you must specify the new table
name to ensure that DB2 Change Management Expert will
generate the correct change commands. Click the Add icon in the upper right
corner of the Table Rename page, select ORG from the
source model list on the left side, and select ORG_new from the target model
list on the right side. DB2 Change Management Expert will
generate a RENAME statement instead of the DROP TABLE ORG and CREATE TABLE
ORG_new commands that would have been generated if you did not specify the
rename activity on the Table Rename tab.
You
can add or delete your table rename selections by using the Add and Delete
icons in the upper right corner of the Table Rename page.
Make
sure that you check the option to Enable data preservation for
the data in the table that you are renaming.

- Generating export and import commands for data preservation.
When you
select the Enable data preservation option on the DDL
Generation Options page of the wizard, the wizard includes pages to specify
information for generating export and import commands. You can create export
commands to save the data from a dropped table to a file and import commands
to insert data from the file into a newly created table.
If you selected
to generate the DDL to undo the changes, export and import commands will also
be generated for undoing the changes.
If DB2 Change Management Expert determines
that data needs to be preserved, the Enable data preservation option
in the Generate Change Commands wizard is checked by default. To skip data
preservation, uncheck the option.
- Generating DB2 maintenance commands.
You can generate statements to
grant and revoke authorization and commands to rebind packages, run statistics
for tables, and flush the package cache so that SQL statements will use updated
statistics.
If you selected to generate the DDL to undo the changes,
maintenance commands will also be generated for undoing the changes.
You
can choose to not generate any DB2 maintenance commands.
- Merging change commands.
If you have already generated your DDL, export
and import commands, or DB2 maintenance commands and regenerate any of these,
you are prompted to merge the changes from the
Previous Change
Commands side of the
Merge Editor to the
Proposed
Change Commands side of the editor. You should consider merging
in the following cases:
- If you want to preserve customization made to a change command file.
- If both generate data migration and generate change commands are being
used, it might be necessary to merge the export and import files.
You can always return to the Generate Change Commands wizard to specify
the generation of commands that were not previously generated or to make changes
to commands that were previously generated.
- Verify that the generated script files are displayed in the Define
Change Command field on the Change Commands page. If you
generated commands to undo the changes, you can click the Undo
Changes tab to see the generated undo script files, which are
displayed on the Undo Changes page.
The following table shows the default
file names that
DB2 Change Management Expert uses
for making database changes:
Table 1. Default file names for change command
filesDefault script file names |
Contains |
deployment_script_name_export.chx |
Data unload commands |
deployment_script_name_deltaddl.chx |
DDL to make the changes |
deployment_script_name_import.chx |
Data load commands |
deployment_script_name_maint.chx |
Rebind commands, runstats commands, REORG commands,
and commands to flush the package cache |
deployment_script_name_auth.chx |
Authorization statements |
The following table shows the default file names that
DB2 Change Management Expert uses for undoing
database changes:
Table 2. Default file names for undo change command
filesDefault script file names |
Contains |
deployment_script_name_undoddl.chx |
DDL to undo the changes |
deployment_script_name_undoimport.chx |
Import commands for undoing the changes |
deployment_script_name_undoauth.chx |
Authorization statements |
deployment_script_name_undomaint.chx |
Rebind commands, runstats commands, and commands to
flush the package cache for undoing the changes |
Important: The script files are deployed in the order
that they appear in the list. Change commands are deployed in the order that
they appear in the script files.
- To view the contents of any change command script file, select
the file and click Edit.
Your change commands are ready for use, and you can go to the Overview
page to deploy them.
Important: If your target model is invalid,
the generated DDL and undo commands might have syntax errors. You can correct
these errors by using the Change Commands Editor. It is recommended that you
fix any errors in the target model before you generate the change commands.