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 use existing index

Re: primary key use existing index

From: Kirill Richine <krichine_at_radss.com>
Date: Thu, 24 Jun 1999 17:33:04 GMT
Message-ID: <37726a7d.270351294@news.cadvision.com>


On Tue, 22 Jun 1999 12:08:24 -0400, "David Freitag" <dovidf_at_net2phone.com> wrote:

>Is there some way that I can specify a primary key constraint so that it
>will use an existing index without rebuilding the index?
>
>

It is possible starting from (I believe) Oracle 8

SQL> create table temp (a varchar2 (10)); Table created.
SQL> create index temp_pk on temp (a);
Index created.
SQL> alter table temp add (constraint temp_pk primary key (a)); Table altered.

Note that if the index is not unique, then you can disable the constraint without losing the index. Yet, when the constraint is enabled, you still get uniqueness enforcement:

SQL> insert into temp values ('A');
1 row created.
SQL> /
insert into temp values ('A')

            *
ERROR at line 1:
ORA-00001: unique constraint (TEMP.TEMP_PK) violated Received on Thu Jun 24 1999 - 12:33:04 CDT

Original text of this message

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