码迷,mamicode.com
首页 > 数据库 > 详细

Oracle 查询字段在什么表

时间:2014-08-29 17:47:38      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   div   log   sp   on   c   ef   

 

 -- 查询字段在什么表

select * from all_tab_cols t where t.column_name=ABC;

 

-- 查询字段在什么表并且 判断是否是主键

select * 
       from all_tab_cols t 
       left join (
         select a.table_name, a.constraint_name,  a.column_name, b.constraint_type -- 字段约束类型(P:主键)  
           from user_cons_columns a
           inner join user_constraints b  
                 on a.constraint_name = b.constraint_name  
           -- and b.constraint_type = ‘P‘ 
       ) tc
         on 1=1 
         and t.table_name = tc.table_name
         and t.column_name = tc.column_name
       where 1=1
       and t.column_name =  PK_PSNDOC‘  -- 要查询的字段
       and tc.constraint_type = P  -- 判断是否为主键
       ORDER BY t.table_name 

 

Oracle 查询字段在什么表

标签:style   blog   color   div   log   sp   on   c   ef   

原文地址:http://www.cnblogs.com/wuyifu/p/3945295.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!