Managing Primary Keys
Last modified: June 26, 2023
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 Null. A table or view can have only one primary key.
Creating Primary Keys
- Open a table and select New Primary Key on the dbForge 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 the shortcut menu.
Editing Primary Keys
- Navigate to the key in Database Explorer and double-click it or open the table that owns the primary key.
- Switch to the Constraints tab and choose Edit Constraint on the shortcut menu.
Dropping Primary Keys
- Navigate to the key in Database Explorer.
-
Select Delete on the shortcut menu.
-or-
- Open the table that owns the primary key.
- Switch to the Constraints tab.
- Select Delete Constraint on the key shortcut menu.
Was this page helpful?