Automatic Indexes under 10gR2
Michael, February 05, 2007 - 9:46 am UTC
Hi Tom,
... hey, first review after 6 years ...
with 10gR2 it seems that automatic created indexes are coded in the field property in the table sys.ind$. If bitand(property,4096)=4096 then it is system generated, bitand(property,1)=1 indicates a unique index. Thus, for a system generated index for a unique constraint the property is 4097.
As user TEST_A:
create table tab(x number, y number);
-- create index and then create unique constraint
create unique index uq_tab_1 on tab(x);
alter table tab add constraint uq_tab_1 unique(x);
-- create unique constraint without an existing unique index
alter table tab add constraint uq_tab_2 unique(y);
As user SYS:
select i.property, o.name
from obj$ o, ind$ i
where i.obj# = o.obj#
and o.owner# = ( select user_id from dba_users where username='TEST_A' );
Result is:
property name
1 UQ_TAB_1
4097 UQ_TAB_2
Unfortunately I didn´t find a description for the IND$-Table in Metalink, so I can´t verify my assumption.