您的位置:首页 > 博客中心 > 数据库 >

Oracle 查询字段在什么表

时间:2022-03-13 23:09

 

 -- 查询字段在什么表

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 

 

热门排行

今日推荐

热门手游