Results 1 to 3 of 3

Thread: unique key

  1. #1
    Join Date
    Oct 2007
    Posts
    246

    Unanswered: unique key

    hi

    unique key won,t allow null values
    more than one unique key can be created in a table
    unique key won,t allow duplicate values
    unique key default creates a indexe

    What is the major difference unique and primary key ??

    regds
    Paul

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by Mathew_paul View Post
    unique key won,t allow null values
    are you sure?

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    Quote:
    Originally Posted by Mathew_paul
    unique key won,t allow null values
    are you sure?
    Yes, unique constraint don't allow null values.
    unique constraint and unique index are different things.

    Descriptions of UNIQUE (column-name,...) and PRIMARY KEY (column-name,...)
    in TABLE statement in "DB2 SQL Reference" are essentialy same, except...
    Only one primary key can be defined on a table.
    Another use of PRIMARY KEY is...
    REFERENCES table-name or nickname

    .....
    .....

    (column-name,...)

    .....
    .....

    The list of column names must match the set of columns (in any
    order) of the primary key or a unique constraint that exists on T2
    (SQLSTATE 42890). If a column name list is not specified, then T2
    must have a primary key
    (SQLSTATE 42888). Omission of the
    column name list is an implicit specification of the columns of that
    primary key in the sequence originally specified.
    Last edited by tonkuma; 12-30-09 at 10:55.

Posting Permissions

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