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: Jeremiah Wilton <jeremiah_at_wolfenet.com>
Date: Fri, 22 Jan 1999 09:01:38 -0800
Message-ID: <Pine.OSF.4.02.9901220758290.22099-100000@gonzo.wolfenet.com>


On Fri, 22 Jan 1999, David Lane wrote:
>
> We create the index first with the parallel option to speed things up ....
> if you then add a primary key with EXACTLY the same name as the index,
> Oracle uses the index to enforce the constraint rather than creating a new
> index. The same works for unique constraints.
>
> 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.

Oracle allows nullable columns to be part of a unique index, but the columns in a primary key must be not null. Primary keys use unique indexes to enforce uniqueness. As David points out, you can add a PK on top of an existing unique index without rebuilding that index. Many products and features rely on the constraint definitions in Oracle to do various things, so there is no great reason to avoid primary keys if you are just going to use a unique index for the same purpose.

--
Jeremiah Wilton http://www.wolfenet.com/~jeremiah Received on Fri Jan 22 1999 - 11:01:38 CST

Original text of this message

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