Add a key constraint

Key constraints in System i Navigator consist of primary and unique keys. When joined with a foreign key, they create a referential constraint.

If you are adding a key to a new table, follow the instructions for creating a table and begin with step 6 when you get to the Table Properties dialog.

  1. In the System i Navigator window, expand the system you want to use.
  2. Expand Databases.
  3. Expand the database and schema that you want to work with.
  4. Click the Table container.
  5. Right-click the table to which you want to add the key and select Definition.
  6. On the Table Definition dialog, select the Key Constraints tab.
  7. On the Key Constraints tab, click New.
  8. On the New Key Constraint dialog, specify a name in the name text box. If no name is specified, the system automatically generates a name.
  9. Select the column to which you want to add the key.
  10. Select Primary to create a primary key or Unique to create a unique key.
  11. Click OK to return to the Table Definition dialog.
  12. Click OK to create the key.

Note: You may modify a constraint only if it has been defined during your current table editing session. If you added the constraint and then clicked OK on either the New Table dialog or Table Definition dialog, then you have read-only access for the constraint. If you want to change the constraint properties, you must drop the constraint and then recreate it with the appropriate changes.