Re: Unique and non unique index
- From: Walt <walt_askier@xxxxxxxxxxxxxx>
- Date: Wed, 15 Mar 2006 09:29:26 -0500
Rama Shankar wrote:
Hi All,
We can enforce primary key constraint by using both unique
and non-unique index. I want to know when to use unique index and when
non unique.
If you want to enforce a primary key constraint, create a primary key for the table. Oracle will take care of creating the associated index automagically.
If some column other than the PK needs to be unique, create a unique *constraint*, not a unique index. Again, Oracle will take care of creating the associated index automagically.
You can use a unique index to enforce uniqueness but this is sub-optimal. Among other things you can foreign key to a column that has a unique constraint, but you can't foreign key to a column that has it's uniqueness enforced by an index.
If you need an index for performance reasons, create a non-unique index.
//Walt
.
- References:
- Unique and non unique index
- From: Rama Shankar
- Unique and non unique index
- Prev by Date: Re: Format Numbers Oracle
- Next by Date: Re: Unique and non unique index
- Previous by thread: Re: Unique and non unique index
- Index(es):
Relevant Pages
|