Unique and Primary Keys

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

  1. In the Database Explorer window, right click a required table.
  2. Click Edit Table on the shortcut menu.
  3. On the Table menu, click either New Primary Key or New Unique Key.
  4. 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

Overview

Take a quick tour to learn all about the key benefits delivered by dbForge Studio for Oracle.
All Features

All features

Get acquainted with the rich features and capabilities of the Studio in less than 5 minutes.
Request a demo

Request a demo

If you consider employing the Studio for your business, request a demo to see it in action.
Ready to start using dbForge Studio for Oracle?