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: Primary key or no primary key

Re: Primary key or no primary key

From: Jurij Modic <jmodic_at_src.si>
Date: Thu, 21 Jan 1999 21:03:05 GMT
Message-ID: <36a78dc5.5087637@news.siol.net>


On Thu, 21 Jan 1999 13:52:42 GMT, kshave_at_my-dejanews.com wrote:

>Primary key or no primary key When a table is created and a primary key
>constraint is defined, a unique index is automatically set up for that
>constraint. Would there be any advantage or disadvantage to simply creating
>the index yourself and not defining a primary key for the table. A unique
>index is created in either case.
>
>I've looked through all of Oracle's books and I could not find an answer. Does
>anybody have any input?

As far as data integrity is concerned:
Unique index + NOT NULL on all of the indexed columns will guarantee exactly the same uniqueness as the primary key constraint would.

As far as referential integrity is concerned: Using only unique index without an explicit PRIMARY KEY or UNIQUE KEY constraint will prevent you to create any foreign key referencing the indexed columns.

As far as performance is concerned:
I can't see any reason why using only unique index instead of a constraint would be preferable.

To summarise: I can see no reason why one would prefer using unique indexes over PKs or UKs, but I can see some reasons why one would prefer using explicit PK/UK constraints over the unique indexes.

>-Keith

HTH, Jurij Modic <jmodic_at_src.si>
Certified Oracle7 DBA (OCP)



The above opinions are mine and do not represent any official standpoints of my employer Received on Thu Jan 21 1999 - 15:03:05 CST

Original text of this message

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