Unique and Primary Keys
Last modified: March 13, 2025
The UNIQUE constraint uniquely identifies each record in a database table. The UNIQUE and PRIMARY KEY constraints both provide a guarantee for uniqueness for a column or set of columns. A PRIMARY KEY constraint automatically has a UNIQUE constraint defined on it. Note that you can have many UNIQUE constraints per table, but only one PRIMARY KEY constraint per table.
Certain restrictions must be obeyed when working with unique and primary keys:
- A table or view can have only one primary key.
- A composite key cannot have more than 32 columns.
- You cannot designate the same column or combination of columns as both a primary key and a unique key.
- Some column types such as LOB, LONG, VARRAY, NESTED TABLE, REF are not supported for unique or primary keys.
Creating and Editing a Key
- In the Database Explorer window, right click a required table.
- Click Open Editor on the shortcut menu.
- On the Table menu, click either New Primary Key or New Unique Key.
- Add required columns to the key and click OK.
When the Table Editor is open, you can switch to the Constraints tab, and create (or edit) a key using the shortcut menu.
To delete a key, select a required key, and click Delete Constraint on the shortcut menu.
Want to find out more?
Overview
Take a quick tour to learn all about the key benefits delivered by dbForge Studio for Oracle.
All features
Get acquainted with the rich features and capabilities of the tool in less than 5 minutes.
Request a demo
If you consider employing this tool for your business, request a demo to see it in action.