Primary keys

Last modified: October 1, 2024

A primary key constraint designates a column as the primary key of a table or view. A composite primary key designates a combination of columns as the primary key. A primary key combines a Not Null and unique constraint in one declaration. Therefore, to satisfy a primary key constraint no primary key value can appear in more than one row in the table, and no column that is part of the primary key can contain a Null. A table or view can have only one primary key.

To create a primary key:

Open the table you need and choose New Primary Key from the Table menu. Add required columns to the key and click OK. You can also switch to the Constraints tab and create the primary key within shortcut menu.

To edit a primary key:

Navigate to the key in Database Explorer and double-click it or open the table that owns the primary key, switch to Constraints tab and choose Edit Constraint from shortcut menu.

Note

The already created Primary key can be edited only on the Constraints page. The Primary check box is inactive on opening a column.

To drop a primary key:

Navigate to the key in Database Explorer and, and then click Delete on its shortcut menu. Alternatively, open the table that owns the primary key, switch to the Constraints tab, and then click Delete Constraint on the key shortcut menu.