Hive Metastore sql 关联查询出Hive Table字段

时间:2021-04-24 23:09:38
解析存储Hive Meta的几张表,然后我们选择
SDS 数据存储信息表
COLUMNS_V2 字段信息表
这两张表

然后利用查询操作即可查询出指定的database and table的字段信息:

求字段未排序的结果:

select COLUMN_NAME from COLUMNS_V2 t left join SDS t2 on t.CD_ID = t2.CD_ID where t2.LOCATION = "hdfs://localhost:8020/apps/hive/warehouse/database_name/table_name”;

求排序后的结果:
select COLUMN_NAME from COLUMNS_V2 t left join SDS t1 on t.CD_ID = t1.CD_ID where t1.LOCATION = "hdfs://localhost:8020/apps/hive/warehouse/database_name/table_name" order by t.INTEGER_IDX;