Query-find table which have neither Primary nor Unique key
557703Jul 8 2011 — edited Jul 8 2011hi ,
I am bit novice in query writing. But I need to list all those table in 9i database which have neither primary key nor Unique key constraints.
I use the follwing query to find the tables having either primary or unique key constraints ( atleast one)
select OWNER,TABLE_NAME from dba_constraints where CONSTRAINT_TYPE IN ('P','U')
and OWNER not in ('SYS','SYSTEM') order by OWNER, TABLE_NAME
Now to list those tables which have none of constraints either Primary or unique key constraints I could use
select OWNER,TABLE_NAME from dba_constraints where CONSTRAINT_TYPE NOT IN ('P','U')
and OWNER not in ('SYS','SYSTEM') order by OWNER, TABLE_NAME
but this query list large no of tables ( multile name for same tables as some tables has multilpe constraints other that PK , UK) how can I use 'distinct ' to list table name only once. I also need 'owner' in the query.
Thanx in advance.
Regards
Amit