Is there a way to find if PK was created with the index or alter + change?

Is there a way to determine if a primary key (PK) was created by one or the other method:

Method 1:
ALTER table add constraint tab1_pk primary key (pk) tab1;

Method2:
create an index only tab2_pk on tab2 (pk);
ALTER table add constraint tab2_pk primary key (pk) tab2.

When you remove or disable the PK, then in method 1 the corresponding index is also removed, but in method 2 the index is not deleted. Before a bulk loading, I would like to know if I need to issue another statement to delete the index in method 2

Thank you

The column spare1 in the sys.obj$ will be '0' in the method 1 and '6' in method 2.

select a.name, a.spare1 from sys.obj$ a, sys.ind$ b
where name in ('TAB1_PK', 'TAB2_PK')
and a.obj# = B.obj#;

Published by: Lacotte Renaud on December 16, 2009 09:53

Tags: Database

Similar Questions

Maybe you are looking for