Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: UNIQUE and PK

Re: UNIQUE and PK

From: Howard J. Rogers <howardjr2000_at_yahoo.com.au>
Date: Thu, 25 Jul 2002 06:40:27 +1000
Message-ID: <ahn3aa$8m6$1@lust.ihug.co.nz>


"Primary Key" means "not null plus unique".

Therefore, you don't put all three on the one column, you just make it the primary key, and that takes care of the other two.

If you've already got a unique constraint preventing the creation of a primary key, drop it and create the primary key constraint on its own instead.

Put it another way: a column declared to be unique is guaranteed unique for every row, except that you are allowed any number of rows which leave the column null, because null can't be compared to null, and therefore there's no basis for testing that one null is duplicating another null. A Primary Key also guarantees uniqueness for every row, but since every row must have an evaluate-able identifier, nulls are not permitted. Hence PK=UQ+NN

Regards
HJR "zeb" <thierry.constant1_at_free.fr> wrote in message news:3d3f0005$0$445$626a54ce_at_news.free.fr...
> Hi,
>
> I have a DB ( 7.3.2. AIX )
> for some tables, i have
> the constraints:
> NOT NUL, UNIQUE and PRIMARY KEY for the same column
>
> How is it possible ????
>
> If there a UNIQUE
> when I try to put a PRIMARY KEY
> I get:
> ORA-02261 such unique or primary key already exists in the table
>
> and the same for the reverse
>
> How can you explain this situation ???
>
> Thanks in advance
>
>
>
Received on Wed Jul 24 2002 - 15:40:27 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US