Thursday, September 13, 2018

Hive query to list all the tables with partitions



Query 1:

Run in Hive Metastore Backend Oracle Database

select distinct TBLS.TBL_NAME, DBS.NAME--,PARTITIONS.PART_NAME,SDS.LOCATION,TBLS.DB_ID
from TBLS,PARTITIONS,DBS
where TBLS.DB_ID=249847
and TBLS.TBL_ID=PARTITIONS.TBL_ID
and DBS.DB_ID = TBLS.DB_ID
order by 1--,2;


Query 2:
select distinct TBLS.TBL_NAME, DBS.NAME--,PARTITIONS.PART_NAME,SDS.LOCATION,TBLS.DB_ID
from TBLS,PARTITIONS,DBS
where TBLS.TBL_ID=PARTITIONS.TBL_ID
and DBS.DB_ID = TBLS.DB_ID
order by 2,1;