学无止境
分类: Oracle
2009-12-25 16:08:09
查找主键中有name字段的表:
select a.owner,a.table_name from dba_cons_columns a,dba_constraints b
where a.owner=b.owner
and a.constraint_name=b.constraint_name
and b.constraint_type='P'
and a.column_name='NAME';
查找只用name字段作为主键的表:
select b.owner,b.table_name,c.column_name from dba_constraints b,(select constraint_name,count(*) cnt from dba_cons_columns
group by constraint_name
having count(*)=1) a,
dba_cons_columns c
where b.constraint_type='P'
and a.constraint_name=b.constraint_name and c.constraint_name=a.constraint_name and c.column_name='NAME';