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)

    An absolute can only be given in an intuition, while all the rest has to do with analysis. We call intuition here the sympathy by which one is transported into the interior of an object in order to coincide with what there is unique and consequently inexpressible in it. Analysis, on the contrary, is the operation which reduces the object to elements already known.
    Henri Bergson (1859–1941)

    McCoy: That shark’s been following us ever since the surgeon died, waiting for the burial. Couldn’t I have a musket to shoot it, sir?
    Fletcher Christian: Take the deck, McCoy. I’ll get the keys to the arms chest.
    McCoy: Get two muskets, sir. I’d like to shoot that shark on board.
    Talbot Jennings (1896–1985)