Primary KeysAn application might require that database table contain one or more columns that can uniquely identify a row. For example, in a supplier table, it is necessary that the column supp_no uniquely identify a row. Every row of the table is uniquely identified by this column value. A single column or a group of columns that is the principal unique identifier of the table is referred to as the primary key. A table can contain only one primary key constraint. The following example shows the creation of a primary key column on the table supplier. CREATE TABLE supplier ( supp_no INTEGER NOT NULL PRIMARY KEY, name CHAR (30), status SMALLINT, city CHAR (20) ) ; During an INSERT operation, if a duplicate value is given for a primary key column, the INSERT operation results in an error. |
|||