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;
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了