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

Home -> Community -> Usenet -> c.d.o.misc -> Re: What makes difference by creating an index or add a primary key to a table

Re: What makes difference by creating an index or add a primary key to a table

From: Daniel Morgan <damorgan_at_exxesolutions.com>
Date: Sat, 09 Aug 2003 09:37:26 -0700
Message-ID: <3F352345.AA41F1CA@exxesolutions.com>


cschang wrote:

> System: 8.1.7
> Platform: NT 4 w/sp6a
> I have a table that I decided to add a primary key by combining two
> columns. But what that difference to create an index of the table by
> using these two columns?
>
> C Chang

The two objects serve entirely different purposes. The purpose of a constraint is to enforce data integrity. The only purpose of an index is to enhance performance.

If one looks more specifically at the differences between a primary key constraint and a unique constraint (reasonably similar to a unique index) there are still differences. Most obviously ... a table can have only a single primary key but many unique constraints ... and a unique constraint allows NULLs whereas you can not have a NULL primary key.

--
Daniel Morgan
http://www.outreach.washington.edu/extinfo/certprog/oad/oad_crs.asp
damorgan_at_x.washington.edu
(replace 'x' with a 'u' to reply)
Received on Sat Aug 09 2003 - 11:37:26 CDT

Original text of this message

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