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: orace sql query

Re: orace sql query

From: DA Morgan <damorgan_at_psoug.org>
Date: Sun, 24 Jun 2007 09:52:43 -0700
Message-ID: <1182703964.112505@bubbleator.drizzle.com>


Charles Hooper wrote:

> On Jun 23, 6:18 pm, DA Morgan <damor..._at_psoug.org> wrote:

>> Charles Hooper wrote:
>>> I am now a bit confused on this topic, or are we reading things
>>> differently?
>>> Create a generic table without a primary key:
>>> CREATE TABLE T1 (
>>> C1 VARCHAR2(20),
>>> C2 VARCHAR2(20));
>>> Table created.
>>> Create a unique index on the C1 column of the table:
>>> CREATE UNIQUE INDEX IND_T1 ON T1(C1);
>>> Index created.
>>> Specify that column C1 is the primary key for T1:
>>> ALTER TABLE T1 MODIFY (PRIMARY KEY (C1));
>>> Table altered.
>>> Take a look at the indexes for the table:
>>> SELECT
>>> INDEX_NAME
>>> FROM
>>> DBA_INDEXES
>>> WHERE
>>> TABLE_NAME='T1';
>>> INDEX_NAME
>>> ----------
>>> IND_T1
>>> DROP INDEX IND_T1;
>>> ERROR at line 1:
>>> ORA-02429: cannot drop index used for enforcement of unique/primary
>>> key
>>> The above seems to be in agreement with the posts by David
>>> Fitzjarrell, Ed Stevens, Frank van Bortel, and the Oracle
>>> documentation. Or, is this not a valid test?
>>> Charles Hooper
>>> IT Manager/Oracle DBA
>>> K&M Machine-Fabricating, Inc.
>> I know what the error message says.
>>
>> And I know what the document Frank posted the link to says.
>>
>> And until corrected by someone I stand by what I wrote.
>>
>> Consider this:
>>
>> SQL> select constraint_name, constraint_type, deferrable
>> 2 from user_constraints
>> 3 where table_name = 'UCLASS';
>>
>> CONSTRAINT_NAME C DEFERRABLE
>> ------------------------------ - --------------
>> PK_UCLASS P DEFERRABLE
>> CC_UCLASS_CLASS_NAME C NOT DEFERRABLE
>>
>> SQL> SELECT index_name, index_type, uniqueness
>> 2 FROM user_indexes
>> 3 WHERE table_name = 'UCLASS';
>>
>> INDEX_NAME INDEX_TYPE UNIQUENES
>> ------------------------------ --------------------------- ---------
>> PK_UCLASS NORMAL NONUNIQUE
>>
>> SQL> DROP INDEX pk_uclass;
>> DROP INDEX pk_uclass
>> *
>> ERROR at line 1:
>> ORA-02429: cannot drop index used for enforcement of unique/primary key
>>
>> I don't believe a non-unique index is being used for enforcement of
>> a unique condition. Any comment Tom? Jonathan? Richard? Howard? Except
>> to speed the up the search.
>> --
>> Daniel A. Morgan
>> University of Washington
>> damor..._at_x.washington.edu (replace x with u to respond)
>> Puget Sound Oracle Users Groupwww.psoug.org
> 
> A little more information on Oracle using non-unique indexes to
> enforce primary keys:
> http://asktom.oracle.com/pls/asktom/f?p=100:11:1651918238161457::::P11_QUESTION_ID:2913600659112
> "Since version 8.0 with deferrable constraints, we've only needed AN
> INDEX to enforce uniqueness.
> Not a unique index, just an index."
> 
> Charles Hooper
> IT Manager/Oracle DBA
> K&M Machine-Fabricating, Inc.

But it does NOT use the index to enforce the constraint. Just to speed the lookup for the value.

-- 
Daniel A. Morgan
University of Washington
damorgan_at_x.washington.edu (replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
Received on Sun Jun 24 2007 - 11:52:43 CDT

Original text of this message

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