当前用户下没有主键也没有唯一性索引的表
1、查询当前用户下没有主键的表
select
from user_tables a
where exists (select table_name
from user_constraints b
where b.constraint_type = 'P'
and a.table_name = b.table_name);
2、查询当前用户下含有唯一性索引的表
select distinct cu.table_name
from user_cons_columns cu, user_constraints au
where cu.constraint_name = au.constraint_name
and au.constraint_type = 'U') T
where u.table_name = T.table_name;
3、当前用户下,既没有主键也没有唯一性索引的表
select table_name
from user_tables u
where not exists
(select table_name
from (select table_name
from user_tables a
where exists (select *
from user_constraints b
where b.constraint_type = 'P'
and a.table_name = b.table_name)
union
select distinct cu.table_name
from user_cons_columns cu, user_constraints au
where cu.constraint_name = au.constraint_name
and au.constraint_type = 'U') T
where u.table_name = T.table_name)
and u.table_name not like '%$%';