Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Primary key or no primary key
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)
![]() |
![]() |