Creating a Primary Key

Creating a primary key constraint ensures that no two rows in a table have the same values in the specified columns.

A primary key is a column or combination of columns that uniquely identifies a row. It cannot be NULL and it must have a unique index. A table with a primary key is eligible for joins with foreign keys in other tables. Think of the primary key table as the master table in a master-detail relationship. There can be many such master-detail groups in a database.

  1. In the Perspective Resources view, select the server on which the table resides, then click the drop-down arrow next to the server name and select Administration Console.
  2. In the left pane of the Administration Console, expand ASE Servers > Schema Objects > Tables, then choose one of the following:
    • User Tables
    • Proxy Tables
  3. Select the table for the primary key.
  4. Select Properties.
  5. From the Table Properties window, select Index > Unique Constraint.
    You see the Add Unique Constraint wizard.
  6. Specify a name, then select Primary key.
  7. (Optionally) Click Make supporting index clustered.
  8. Select the columns to include in the primary key.
  9. Select a segment on which to place the primary key.
  10. (Optional) Specify a fill factor percentage.
  11. (Optional) Specify the maximum number of rows per page for the index.
  12. (Optional) Specify the ratio of empty pages to filled pages to provide for expansion.
  13. (Optional) Click Summary to verify your selected options.
Related tasks
Creating a Check Constraint
Creating a Unique Constraint
Creating a Foreign Key
Binding Defaults and Rules to a Column