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: Daniel Morgan <damorgan_at_exxesolutions.com>
Date: Tue, 02 Sep 2003 16:39:25 -0700
Message-ID: <1062545942.748297@yasure>


Marko Kimpel wrote:

>>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
>
>

Try looking at my example again.

I didn't write:

CREATE TABLE
CREATE INDEX
ALTER TABLE ADD CONSTRAINT, If a developer follows the directions I wrote there can NOT be any index present and thus the scenario you present is impossible.

-- 
Daniel Morgan
http://www.outreach.washington.edu/ext/certificates/oad/oad_crs.asp
http://www.outreach.washington.edu/ext/certificates/aoa/aoa_crs.asp
damorgan_at_x.washington.edu
(replace 'x' with a 'u' to reply)
Received on Tue Sep 02 2003 - 18:39:25 CDT

Original text of this message

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