oracle中查询表字段信息及主键字段

select 
    a.owner,
    a.table_name,
    a.column_name,
    a.data_type,  
    d.constraint_type,
    a.num_nulls 
from all_tab_columns a
left join 
 (    select 
        b.owner,
        b.TABLE_NAME,
        column_name,
        constraint_type 
      from all_cons_columns  b
     join all_constraints c
      on b.CONSTRAINT_NAME=c.CONSTRAINT_NAME
      and b.table_name=c.table_name
      and b.owner=c.owner
      and c.constraint_type='P'  --type为P表示为主键值,还有关于外键等
  ) d
on a.owner=d.owner 
and a.table_name=d.table_name 
and a.column_name=d.column_name 
where 1=1 
and a.table_name='C_ACCOUNT' 
and a.owner in ('AQDFCS','SDVD')

 

上一篇:oracle数据库备份时空表无法备份问题


下一篇:Java 面试灵魂拷问之MySQL事务原理