1

I'm looking for a script to find tables within my database that have no primary key.

0

2 Answers 2

4
select table_name from user_tables
minus
select table_name 
from all_constraints
 where (constraint_type ='P' ) and owner='dbSID_here'
0

There's an easier way:

SELECT table_name FROM user_tables WHERE table_name NOT IN ( SELECT table_name FROM user_constraints WHERE constraint_type ='P' );

from here.

Not the answer you're looking for? Browse other questions tagged or ask your own question.