Previous Topic

Next Topic

Column-Level Primary Key Constraint

In a database table, there might be only one column that distinguishes the given row from other rows. That is, a single column is the unique identifier of the table. For example, the column supp_no is a column level primary key of the table supplier.

Column-level primary key constraints are defined in the column definitions of a table. The following example shows the creation of the column-level primary key on the supplier table.

CREATE TABLE supplier (
     supp_no     INTEGER NOT NULL PRIMARY KEY,
     name        CHAR (30),
     status      SMALLINT,
     city        CHAR (20)
) ;

In the above example, the column supp_no is a unique identifier of the table supplier and the key consists of only one column. Hence it is defined at column level.