Add and remove constraints to a table

Constraints can be added to a new table or to an existing table. You can add a unique or primary key, a referential constraint, or a check constraint, using the ADD constraint clause on the CREATE TABLE or the ALTER TABLE statements.

For example, add a primary key to a new table or to an existing table. The following example illustrates adding a primary key to an existing table using the ALTER TABLE statement.

ALTER TABLE CORPDATA.DEPARTMENT         
  ADD PRIMARY KEY (DEPTNO)

To make this key a unique key, replace the keyword PRIMARY with UNIQUE.

You can remove a constraint using the same ALTER TABLE statement:

ALTER TABLE CORPDATA.DEPARTMENT         
  DROP PRIMARY KEY (DEPTNO)