Unique Keys Wizard (DB2 LUW)

From DBArtisan
Jump to: navigation, search

Go Up to IBM DB2 for Linux, Unix, and Windows Object Wizards

A unique key constraint is a key for which no two of its values can be equal and no values can be null. A table can have a number of unique constraints, but it cannot have more than one unique constraint on the same set of columns. If you are creating a unique key constraint on a table that already exists (as opposed to creating a unique key at the time the table is first generated), a unique index must already exist on the columns of the unique key you want to constrain. If no unique index exists, the Index Wizard will open as you complete the Create Unique Key Constraint dialog.

To create a new unique key using a wizard:

  1. Open a creation wizard for a unique key. For details, see Opening an Object Wizard.
  2. Use the following topics as a guide to setting properties and performing tasks as you pass through the wizard panels:
  3. Finally, use the Execute button to create the object.

Unique Keys (DB2 LUW) - Properties

When creating or editing a unique key, this tab/panel lets you work with the following settings:

Setting Description

Table Schema and Table Name

Choose the owner and name of the table in which the unique key is being created.

Name

Provide a name for the unique key being created.

Time period policy

This setting is for use with tables set up as business-time tables. For more information, see Tables (DB2 LUW v10) - Temporal Properties. When selected, a BUSINESS_TIME WITHOUT OVERLAPS option is specified against the column or columns defining the constraint, in the generated DDL. This ensures that values for the constraint columns are unique with respect to the time for the BUSINESS_TIME period. When you select this option, columns specified as business-time begin period and end period are not available as candidates on the Columns tab/panel.

Unique Keys (DB2 LUW) - Columns

From the Column dropdown, select a column for the primary key and specify a Sort option. To add more columns, click the New button and then follow the steps in the last instruction. Use the Delete button to drop columns.