Using UNIQUE constraints on columns or tables

The UNIQUE constraint specifies that one or more columns uniquely identify each row in the table. If you apply the UNIQUE constraint, Sybase IQ enforces this condition.

UNIQUE is essentially the same as a PRIMARY KEY constraint, except that you can specify more than one UNIQUE constraint in a table. With both UNIQUE and PRIMARY KEY, columns must not contain any NULL values.

Example 1

The following example adds the column ss_number to the employee table, and ensures that each value in it is unique throughout the table.

ALTER TABLE employee 
ADD ss_number char(11) UNIQUE 

Example 2

In this example, three columns are needed to make a unique entry.

ALTER TABLE product
ADD UNIQUE (name, size, color)