Previous Topic

Next Topic

Column-Level Candidate Key Constraint

In an application, it might be necessary that a column be specified as the unique column. For example, the column ss_no in table employee must be unique, since it contains an employee’s Social Security number. Such a unique column can be specified using the column level candidate key constraint.

A column-level candidate key constraint contains only one column as a candidate key. It is specified in the column definition. Consider the following example:

CREATE TABLE employee (
     empno        INTEGER NOT NULL PRIMARY KEY,
     ss_no        INTEGER NOT NULL UNIQUE,
     ename        CHAR (19),
     sal          NUMERIC (10, 2),
     deptno       INTEGER NOT NULL
) ;

In the above example, the column ss_no is the candidate key of the table employee.