Re: Help: Confused with Primary Key and Index

From: Lothar Armbrüster <la_at_oktagramm.de>
Date: Thu, 22 Mar 2001 18:28:51 +0100
Message-ID: <PM0003801BDF778B26_at_hades.unknown.dom>


u132781982_at_spawnkill.ip-mobilphone.net wrote:
> Sorry if my question sounds stupid,
> when you create a primary key, does
> oracle always create an index associate
> with that primary key? Will this index
> have the same name as your primary key?
>
Yes, in the general case (i.e. disregarding some specialties like index organized tables) Oracle enforces primary keys with a unique index. [Quoted] When you create the primary key as a constraint with a given name the index gets this name:

[Quoted] alter table my_tab add constraint pk_my_tab primary key(my_id);

If you don't give your constaint a name you get a system generated one and the index in namaed after the constraint (AFAIK). If you specify the primary key constraint as a column constraint you get a system generated name too:

creste table my_tab (my_id number(5) primary key);

> If the table is partitioned, can we also
> partitoned the index as well? How can you
> know this index is from primary key or is
> a pure index?

Yes, you can create partitioned indexes. The index partitions get the same partition scheme as the table. I think, you have to add the partition key as the first indexed column to archieve this, but I'm nut quite sure about this.
Have a look at user_ind_partitions and user_partition_indexes to find out about partitioned indexes.
I also remember weakly about local and global indexes in that context, but you will have to look in the docs to get more info on this.

Hope that helps,
Lothar

-- 
Lothar Armbrüster       | la_at_oktagramm.de
Hauptstr. 26            | la_at_heptagramm.de
D-65346 Eltville        | lothar.armbruester_at_t-online.de
Received on Thu Mar 22 2001 - 18:28:51 CET

Original text of this message