Primary Keys

A primary key is the column or columns whose values uniquely identify a row in a table.

Each table in a relational database may or may not have a primary key. The primary key is a column or set of columns that allows each row in the table to be uniquely identified. No two rows may have the same value of a primary key.

You can select a primary key from all of the available columns. It is good practice to keep the primary key for each table as compact as possible. If possible, the primary key should be an unsigned integer datatype, rather than char or varchar.

In a table holding information about employees, the primary key may be an ID number assigned to each employee. In the sample database, the table of sales order items has the following columns:
  • An ID, identifying the order to which the item belongs.
  • A line ID, identifying each item on any order.
  • A product ID, identifying the product being ordered.
  • A quantity, showing how many items were ordered.
  • A ship date, showing when the order was shipped.
To identify an item, both the ID and the line ID are required. The primary key is made up of both these columns.
Related tasks
Creating a Primary Key
Editing a Primary Key
Dropping a Primary Key


Created June 25, 2009. Send feedback on this help topic to Sybase Technical Publications: pubs@sybase.com