Management of renamed objects
When a baseline is used as one of the inputs in a comparison, Compare uses the rename table to resolve renamed objects.
The CDL that BMC AMI Change Manager for Db2 generates correctly retains data with objects and table columns and propagates name changes to columns of dependent views. Compare resolves renamed objects, regardless of how many times the names are changed, as long as the name changes were made through either ALTER or Change Manager. In this case, the rename information is recorded in the Change Manager rename table.
Several Change Manager components are involved in managing renamed objects. You can use Specification or Import to create change requests in an alter-type work ID that specify changes to object names, table columns, or view columns. When Analysis processes this alter-type work ID, it generates an -RNAM command in the worklist for each renamed object, table column, or view column. When Execution processes the worklist, it uses the information provided by the -RNAM commands, along with time stamps of when name changes occurred (or were executed). A record of all of the name changes that have been applied and processed is kept.
When a comparison is run with a baseline as one input, the comparison uses the time stamps of both sets of input to select the rename table entries that have occurred within the time frame of the two inputs. The rename information is applied as needed to resolve name changes. A time stamp is stored when a baseline is created and when an -RNAM command is executed.
When you use the Db2 catalog, a DDL file, or a migrate-type worklist as one of the inputs, the time stamp of these sources is considered to be the current time, and name changes are applied from the time the baseline was created up to the current time.
Resolution of renamed objects
The following example shows how renamed objects are resolved:
You create a baseline that includes a table named DCH.TEST. At a later time, you rename the table to DCH.PROD using an alter-type work ID. You then generate CDL that shows the changes to DCH.TEST since the baseline was created. The ALUIN input stream contains the keywords shown in the following figure for a catalog baseline to a Db2 catalog comparison:
Using this input stream, Compare performs the following functions:
- Loads the baseline and the time stamp that is named ACM.BLUNLD202102120001
- Retrieves the current time stamp and object definitions from the Db2 catalog by using the same scope that was specified to create the baseline
- Using the baseline time stamp and the current time stamp, Compare retrieves the rename information about the table from the Change Manager rename table that falls between the two time stamps and applies it to the table definition that was previously retrieved from the Db2 catalog
- The changes to the name of the objects are maintained by Change Manager using the rename table.
- Generates an ALTER command in the CDL file that shows the renaming of the table, plus any additional changes that might have been applied to the table since the baseline was created
If Change Manager was not used to rename the table, Compare would treat DCH.TEST and DCH.PROD as two different objects. It would then generate a DROP command for DCH.TEST and a CREATE command for DCH.PROD in the CDL file. Data will be lost unless you manually update the rename table.
Rename resolution is performed regardless of the time of the comparison. That is, you can perform a roll back comparison that uses the Db2 catalog as the primary input (Compare1) and a baseline as the secondary input (Compare2). If this comparison includes name changes, the objects are renamed back to their old names as specified in the baseline. If either of the Compare inputs are DDL baselines, the correct rename information is probably not in the rename table unless it was manually inserted.
Rename support is not as significant for some objects because no possibility for data loss exists. For example, CDL could be generated to specify changes to index names with DROP and CREATE commands rather than with ALTER commands. But then you would not know if other index attributes also changed because the CREATE command specifies all of the index attributes. The ALTER command specifies only the changed index attributes, which usually results in generating less CDL and might be important when Compare is used for impact analysis.
Considerations for renamed objects
Consider the following items when you plan to rename objects or when you work with renamed objects:
- Use Change Manager to change object names. Using Change Manager enables Compare to resolve renamed objects when they are used in a comparison and eliminates the need to manually update the rename table.
- If you have a set of data structures that contain renamed objects and you have a choice of sending either CDL or DDL to another subsystem, send CDL. Assuming that Compare generates CDL ALTER commands for the renamed objects, CDL is easier to apply on the receiving subsystem. If you send DDL that contains renamed objects, the receiver of the DDL must know the objects that have been renamed and the receiver must manually perform the process of retaining the data that is associated with the renamed objects. If you send DDL, your local modifications might not be retained.
- If you receive DDL that is generated from data modeling tools and that contains renamed objects, you need to create and retain baselines of the DDL and manually update the Change Manager rename table for the objects that have been renamed. If possible, request that the sender of the DDL provide a listing of the renamed objects in a worklist format.
- Compare only resolves renamed objects when a baseline is involved in the comparison and the renamed objects were correctly recorded in the Change Manager rename table.
Related topic