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;
浙公网安备 33010602011771号