List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:September 17 1999 6:33pm
Subject:Re: UNIQUE -vs- PRIMARY KEY
View as plain text  
At 8:54 PM +0300 9/17/99, Michael Widenius wrote:
>>>>>>  "WJ" == WJ Gilmore <gilmore@stripped> writes:
>
>WJ> Hi there.
>WJ> I would like to clear a minor bit of confusion that I have been having
>WJ> regarding the creation of table columns and whether to use PRIMARY KEY
>WJ> or UNIQUE to set up a column that will contain a unique value.
>
>>>  From the docs., it seems as if there is no real distinction between the
>WJ> definition of PRIMARY KEY and UNIQUE. Is this true? I ask this because
>WJ> it seems as if the docs go through quite a bit of trouble to denote each
>WJ> when necessary.
>
>WJ> In short, are they one in the same? If not, could somebody please list
>WJ> the differences?
>
>Hi!
>
>The only difference is that a PRIMARY key is named 'PRIMARY' while an
>UNIQUE KEY may have any name.
>
>Regards,
>Monty


In addition, there may be only one PRIMARY KEY, whereas you can have
multiple UNIQUE indexes (though that is fairly unusual).

A PRIMARY KEY is a UNIQUE index, but a UNIQUE index may not necessarily
be a PRIMARY KEY.

-- 
Paul DuBois, paul@stripped
Thread
UNIQUE -vs- PRIMARY KEYWJ Gilmore15 Sep
  • Re: UNIQUE -vs- PRIMARY KEYBob Kline15 Sep
  • UNIQUE -vs- PRIMARY KEYMichael Widenius17 Sep
    • Re: UNIQUE -vs- PRIMARY KEYPaul DuBois17 Sep