Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2003
    Posts
    12

    Unanswered: Difference: UNIQUE CONSTRAINT vs PRIMARY KEY CONSTRAINT

    What are the additional behaviours that a PRIMARY KEY CONSTRAINT has over a UNIQUE CONSTRAINT ?

    Thanks

    Legolas

  2. #2
    Join Date
    Feb 2002
    Posts
    2,232
    Are you familiar with BOL ? The following is an excerpt from it:

    You can use UNIQUE constraints to ensure that no duplicate values are entered in specific columns that do not participate in a primary key. Although both a UNIQUE constraint and a PRIMARY KEY constraint enforce uniqueness, use a UNIQUE constraint instead of a PRIMARY KEY constraint when you want to enforce the uniqueness of:

    A column, or combination of columns, that is not the primary key.
    Multiple UNIQUE constraints can be defined on a table, whereas only one PRIMARY KEY constraint can be defined on a table.

    A column that allows null values.
    UNIQUE constraints can be defined on columns that allow null values, whereas PRIMARY KEY constraints can be defined only on columns that do not allow null values.

    A UNIQUE constraint can also be referenced by a FOREIGN KEY constraint.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •