Oracle根据用户名和表名查询表的字段和字段类型等信息

1 该用户下所有表的字段筛选方法

select a.column_name as uploadcolumn
  from user_tab_columns a
 where a.data_type = 'VARCHAR2'
   and a.table_name = 'TABLE_A'

注释:查询当前登录用户下的表名为TABLE_A的所有字段类型为varchar2的字段名。

2 查询当前用户下的TABLE_A表中的所有字段名以及注释

select lower(a.column_name) column_name, a.comments
  from user_col_comments a
 where a.table_name = 'TABLE_A'

3 查询当前用户下的表TABLE_A和表TABLE_B中重合的字段的字段名、字段类型、字段注释

select lower(b.column_name) column_name, b.data_type, a.comments
  from user_tab_columns b
  left join user_col_comments a
    on b.column_name = a.column_name
 where b.table_name = 'TABLE_A'
   and a.table_name = 'TABLE_B';

4 查询当前用户下都有哪些表

select *
  from all_tables a
 where a.owner = upper('数据库用户名')
   and a.table_name like '%_DV%';

5 查询表table_a 中colum_a=2873的所有数据以及统计总数

复制代码
select r.*
  from (select n.colum_a,
               n.colum_b,
               n.colum_c,
               n.colum_d,
               n.colum_e,
               n.colum_f,
               count(*) over() total
          from usera.table_a n
         where 1 = 1
           and n.colum_a = '2873') r;
复制代码
posted @   DAYTOY-105  阅读(266)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示