I'm looking for a script to find tables within my database that have no primary key.
2 Answers
select table_name from user_tables
minus
select table_name
from all_constraints
where (constraint_type ='P' ) and owner='dbSID_here'
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.