Unique Key - Defining Unique Keys

Defining Unique Keys

The definition of unique keys is syntactically very similar to primary keys.

ALTER TABLE ADD UNIQUE ( {, }... )

Likewise, unique keys can be defined as part of the CREATE TABLE SQL statement.

CREATE TABLE TABLE_NAME ( id_col INT, col2 CHARACTER VARYING(20), key_col SMALLINT, ... CONSTRAINT key_unique UNIQUE(key_col), ... ) CREATE TABLE TABLE_NAME ( id_col INT PRIMARY KEY, col2 CHARACTER VARYING(20), ... key_col SMALLINT UNIQUE, ... )

Read more about this topic:  Unique Key

Famous quotes containing the words defining, unique and/or keys:

    “Art, if one employs this term in the broad sense that includes poetry within its realm, is an art of creation laden with ideals, located at the very core of the life of a people, defining the spiritual and moral shape of that life.”
    —Ivan Sergeevich Turgenev (1818–1883)

    “One must love humanity in order to reach out into the unique essence of each individual: no one can be too low or too ugly.”
    —Georg Büchner (1813–1837)

    “And yet we constantly reclaim some part of that primal spontaneity through the youngest among us, not only through their sorrow and anger but simply through everyday discoveries, life unwrapped. To see a child touch the piano keys for the first time, to watch a small body slice through the surface of the water in a clean dive, is to experience the shock, not of the new, but of the familiar revisited as though it were strange and wonderful.”
    —Anna Quindlen (b. 1952)