Creating a unique constraint for a table
You can create a new unique (nonprimary) constraint for a table. A table might already have a primary key and none, one, or more unique (nonprimary) constraints.
- 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 existing 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 database, table space, and table (or use wildcard characters). Then, press Enter.
- On the Mixed List panel, type CUC in the Act column adjacent to the table (TB) for which you want to create a unique (nonprimary) constraint.
- On the Create Constraint panel, specify the information about the constraint.
(Optional) Type the name of the constraint.
- Type U for the Constraint Type to create a unique constraint.
- To specify the columns in the constraint, type S to select Constraint Key Columns.
Press Enter.The Constraint Key Mixed List panel is displayed.
ALUSUC2 ER -------------------- Constraint Key Mixed list -------------------
Command ===> Scroll. . PAGE
WORKID . . . . : RDACRJ.UC01 Commands: CANCEL
Table . . . : DEMOCJ.T0110_REFERRAL
Const Name . : UKEY2
(C)opy column from the Table, indicate position in Key Columns
using (A)fter/(B)efore, and press ENTER.
Lines 1 to 7 of 15
More: +
Act Colname Column Type UDT Length Nl FP
************************************ TOP **************************************
A CONSTRAINT KEY .:
PARENT TABLE . .: DEMOCJ T0110_REFERRAL
C REFERRAL_NUM DECIMAL 10 N N
AREA_NUM SMALLINT N N
CASE_NUM DECIMAL 10 N N
CREATION_DT DATE N N
DISCOVERY_DT DATE N N
MAX_HIST_SEQ_NUM SMALLINT N N
CASE_POOL_NUM SMALLINT N N
Specify the columns in the constraint.
Type C in the Act column adjacent to the column name that you want to use.
- Type A in the Act column adjacent to the Constraint Key.
Press Enter.The Constraint Key Mixed List panel is displayed as shown in the following figure. The column specified for the constraint is displayed below the constraint key.
ALUSUC2 ER -------------------- Constraint Key Mixed list -------------------
Command ===> Scroll. . PAGE
WORKID . . . . : RDACRJ.UC01 Commands: CANCEL
Table . . . : DEMOCJ.T0110_REFERRAL
Const Name . : UKEY2
(C)opy column from the Table, indicate position in Key Columns
using (A)fter/(B)efore, and press ENTER.
Lines 1 to 7 of 15
More: +
Act Colname Column Type UDT Length Nl FP
************************************ TOP **************************************
CONSTRAINT KEY .:
L 1 REFERRAL_NUM
PARENT TABLE . .: DEMOCJ T0110_REFERRAL
REFERRAL_NUM DECIMAL 10 N N
AREA_NUM SMALLINT N N
CASE_NUM DECIMAL 10 N N
CREATION_DT DATE N N
DISCOVERY_DT DATE N N
MAX_HIST_SEQ_NUM SMALLINT N N
Press END until the Mixed List panel is displayed.
ALUSMXL ER --------------------------- Mixed List ---------------------------
Command ===> Scroll. . CSR
WORKID . . . . : RDACRJ.UC01 Commands: CANCEL
Type action next to object and press Enter.
E=Edit L=Like D=Drop U=Undo
Objects 2 to 15 of 146
More: - +
Act Object-Type Objects
TS . . . . . DEMOCJ ASCIIN3
TS . . . . . DEMOCJ ASCIIN4
TS . . . . . DEMOCJ CLAIMTS
TB . . . . DEMOCJ T0027_CLAIM
IXU. . . RDACRJ CLAIM
TB . . . . DEMOCJ T0110_REFERRAL
*L UCU. . . DEMOCJ T0110_REFERRAL UKEY2
TB . . . . DEMOCJ T0572_PROG_REF
TS . . . . . DEMOCJ CUST01
TS . . . . . DEMOCJ CUST02
TB . . . . DEMOCJ EXAM_REPRT_CLASS
TB . . . . DEMOCJ EXAMINATION
TS . . . . . DEMOCJ N1- Press END until the WORKID Action Menu is displayed.
- Create or update a unique index for this unique constraint.Now that unique constraint has been created, you can analyze the work ID and execute the worklist.
Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*