Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Is index used for constraint enforcement?
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