Oracle查询库中所有表名、表说明、字段名、字段名说明
在工作中总会遇到表中字段特别多的时候,这时候查询使用*影响效率,所以写了个小方法提供工作效率。
查询表中字段名并拼接
查询表中字段名并拼接
sql 使用的是查询指定表字段
sx 表别名
sx 表别名
public String cxbzzdm(String sql,String sx) {
List<Map<String, Object>> rows = null;
StringBuffer temp = new StringBuffer();
try {
rows = jdbcTemplate.queryForList(sql);
if(!"".equals(sx))sx=sx+".";
for(int i=0;i<rows.size();i++){
temp.append(sx+rows.get(i).get("zdm")+",");
}
} catch ( Exception e ) {
e.printStackTrace();
}
return temp.toString().substring(0,temp.toString().length()-1);
}
查询所有表名:
select t.table_name from user_tables t;
查询所有字段名:
select t.column_name from user_col_comments t;
查询指定表的所有字段名:
select t.column_name from user_col_comments t where t.table_name = 'BIZ_DICT_XB';
查询指定表的所有字段名和字段说明:
select t.column_name, t.column_name from user_col_comments t where t.table_name = 'BIZ_DICT_XB';
查询所有表的表名和表说明:
select t.table_name,f.comments from user_tables t inner join user_tab_comments f on t.table_name = f.table_name;
查询模糊表名的表名和表说明:
select t.table_name from user_tables t where t.table_name like 'BIZ_DICT%';
select t.table_name,f.comments from user_tables t inner join user_tab_comments f on t.table_name = f.table_name where t.table_name like 'BIZ_DICT%';
浙公网安备 33010602011771号