Adding a ROWID and a LOB column to create a base table
Use the following procedure to add a ROWID column and a LOB column to an existing table to create a base table. You can also create a unique index for a ROWID column that is defined as GENERATED BY DEFAULT. A base table must exist before you can create auxiliary objects.
In this task, you perform the following subtasks:
- Display the list of columns.
- Create a ROWID column.
- Create a LOB column.
- Create a unique index for the ROWID column.
- Create the auxiliary objects for the base table.
To display the list of columns
- 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 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 a table.
To create a ROWID column
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.
To create a LOB column
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 LOB column.
- Specify the name of the LOB column.
- Specify BLOB, CLOB, or DBCLOB as the column type.
- Specify the length of the column.
- Specify whether null values are allowed.
- Specify whether the column has a default value.
- Press Enter.
- Press END.The Mixed List panel is displayed. The table is now a base table with an object type of TBB.
To create a unique index for the ROWID column
If the ROWID column is defined as GENERATED BY DEFAULT, a unique index is required for the column.
- On the Mixed List panel, type CIX in the Act column adjacent to the base table.
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.
The Index Key Mixed List panel is displayed, as shown in the following figure:
ALUSIXKX R ---------------------- Index Key Mixed List ----------------------
Command ===> Scroll. .
WORKID . . . . : RDACRJ.ALT01 Commands: CANCEL END
(C)opy columns from the list under TABLE COLUMNS up to make a list under
INDEX KEY. Use (A)fter/(B)efore to position columns under INDEX KEY.
Objects 1 to 3 of 3
More:
Act Colname Column Type UDT Length Nl FP
************************************ TOP **************************************
A INDEX KEY . . . : RDACRJ IXG_FOR_ROWID
TABLE COLUMNS . : RDACRJ TEMP2
C L ROW_ID ROWID N N
OTRACOL CHAR 5 N N
L CLOB CLOB Y N
*********************************** BOTTOM ************************************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 as shown in the following figure. The index key column is displayed below the index key.
ALUSIXKX R ---------------------- Index Key Mixed List ----------------------
Command ===> Scroll. .
WORKID . . . . : RDACRJ.ALT01 Commands: CANCEL END
(C)opy columns from the list under TABLE COLUMNS up to make a list under
INDEX KEY. Use (A)fter/(B)efore to position columns under INDEX KEY.
Objects 1 to 4 of 4
More:
Act Colname Column Type UDT Length Nl FP
************************************ TOP **************************************
INDEX KEY . . . : RDACRJ IXG_FOR_ROWID
L 1 ROW_ID A
TABLE COLUMNS . : RDACRJ TEMP2
L ROW_ID ROWID N N
OTRACOL CHAR 5 N N
L CLOB CLOB Y N
*********************************** BOTTOM ************************************Press END until the Mixed List panel is displayed.
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 base table and the auxiliary objects have been created, you can analyze a work ID and execute a worklist.