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: Is index used for constraint enforcement?

Re: Is index used for constraint enforcement?

From: Marko Kimpel <marko.kimpel_at_gmx.de>
Date: 2 Sep 2003 14:53:26 -0700
Message-ID: <2c165149.0309021353.6edcac4f@posting.google.com>


> Oracle may but you should never allow it. Primary key and unique
> constraints should always be built with the USING INDEX clause forcing
> constraint name and index name to be identical.

USING INDEX clause doesn't force index creation. If an usable index is already existing the pk constraint will use this one instead of creating a new.

Example:

SQL> create table foo(x int);

Table created.

SQL> create index u1 on foo(x);

Index created.

SQL> alter table foo add primary key (x) using index;

Table altered.

The pk will be based on u1. No additional index is created.

SQL> select index_name from user_indexes;

INDEX_NAME



U1

SQL> select constraint_name from user_constraints;

CONSTRAINT_NAME



SYS_C001185686 Received on Tue Sep 02 2003 - 16:53:26 CDT

Original text of this message

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