Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: What makes difference by creating an index or add a primary key to a table
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
![]() |
![]() |