Converting a VARCHAR data type to a LOB data type
BMC AMI Change Manager for Db2
supports the conversion of a VARCHAR or LONG VARCHAR data type to a BLOB or CLOB data type. Converting the data type requires two alter-type work IDs: one to add a ROWID column and unique index for the ROWID column, and another to change the column’s data type.
To convert the data type to a LOB data type, you must analyze and execute both work IDs and worklists. For more information about unloading data that is contained in LOB columns, see Unload-Unicode-LOB-and-XML-data.
In this procedure, you perform the following subtasks:
- Specify the column.
- Add a ROWID column and a unique index.
- Convert the data type.
To specify the column
- On the BMC AMI Change Manager for Db2 Main Menu, select WORKID, and press Enter.
- On the WORKID Action Menu, type the name of the WORKID and select Create A NEW WORKID. Then, press Enter.
- On the Create WORKID panel, specify the information for the work ID.
- Select Alter for the Type.
- (Optional) Specify a Comment to describe the work ID.
- Press Enter.
- Press END.The WORKID Action Menu is displayed. A message displayed in the upper-right corner indicates that the work ID has been added.
- On the WORKID Action Menu, type the name of the WORKID or type a wildcard pattern to display a list of work IDs. Then, select Specify DB2 definitions and press Enter.
- On the Object Specification panel, specify the name of a table space (or use wildcard characters). Then, press Enter.
- On the Mixed List panel, type CO in the Act column adjacent to the table that contains the column defined as a VARCHAR or LONG VARCHAR.
To add a ROWID column and unique index
- On the Table Columns List panel, type I in the Act column adjacent to a column name. Then, press Enter.A blank line is inserted after the line on which you typed I.
- Specify the attributes for the ROWID column.
- Specify the name of the ROWID column.
- Specify ROWID as the column type.
- Type N in the Nl column to indicate that a null value is not allowed.
Type D in the Df column to indicate that the column is defined as GENERATED BY DEFAULT.
- Press Enter.
- Press END.
- From the Mixed List panel, type CIX in the Act column adjacent to the table to which you added the ROWID column.
On the Create Index panel, specify the attributes for the index.
- Specify the owner of the index.
- Specify the name of the index.
- Type U to indicate that the index is unique.
- Specify whether the parent table already exists in the Db2 catalog.
- Type S to select Keys and TB Cols.
- Press Enter.
On the Index Key Mixed List panel, specify the index key.
- Type C in the Act column adjacent to the ROWID column name.
- Type A in the Act column adjacent to the Index Key.
- Press Enter.The Index Key Mixed List panel is displayed. The index key column is displayed below the index key.
Press END until the Mixed List panel is displayed.
- On the Mixed List panel, press END until the WORKID Action Menu is displayed.
- Analyze the alter-type work ID (see Analyzing-an-alter-type-work-ID-and-generating-a-worklist-in-Change-Manager).
- Execute the alter-type worklist (see Executing-an-alter-type-worklist).
To convert the data type
- Repeat Step 1 through Step 4 to create a second alter-type work ID.
- Type the name of the second alter-type WORKID or type a wildcard pattern to display a list of work IDs. Then, select Specify DB2 definitions and press Enter.
- On the Object Specification pane, specify the name of a table (or use wildcard characters). Then, press Enter.
- On the Mixed List pane, type CO in the Act column adjacent to the table that contains the column defined as a VARCHAR or LONG VARCHAR.
- On the Table Columns List panel, type E in the Act column adjacent to the name of the column that is defined as a VARCHAR. Then, press Enter.
On the Table Column Detail panel, change the attributes for the column.
- Specify the name of the LOB column.
- (If necessary) Specify the schema name.
- Specify BLOB or CLOB as the data type for the column.
- Specify the length of the column.
- Specify whether null values are allowed.
- Specify whether the column has a default value.
- Press END until the Mixed List panel is displayed.The table is now a base table with an object type of TBB.
To create the auxiliary objects for the base table, perform one of the following tasks:
- To create objects in a partitioned table space, see Creating-auxiliary-objects-for-a-partitioned-table-space.
- To create objects in a nonpartitioned table space, see Creating-auxiliary-objects-for-a-nonpartitioned-table-space.
Now that the data type has been converted, you can analyze the second work ID and execute the worklist.