當(dāng)前位置:
首頁 >
Hive查询表行数
發(fā)布時(shí)間:2025/7/14
33
豆豆
有時(shí)在大數(shù)據(jù)處理時(shí)需要查詢一些數(shù)據(jù)表的行數(shù),一般我們會(huì)使用
select count(*) from <table>;或者
select count(1) from <table>;進(jìn)行查詢。
如果多個(gè)表項(xiàng),可能會(huì)使用腳本來批量執(zhí)行。
for line in $(cat tables.txt) doecho "tablename :$line";value=$(hive --database databasename --hiveconf v=v1 -S -e "select count(*) from $line;")echo "rows count:$value" done;也可以使用后臺(tái)并行的執(zhí)行方式。
但是這種方式執(zhí)行時(shí)間比較長,有兩種比較快速的方式可以迅速地查到表的行數(shù)信息:
1.從數(shù)據(jù)庫中查詢?cè)獢?shù)據(jù)
select a.TBL_ID, a.TBL_NAME, b.PARAM_KEY, b.PARAM_VALUE from TBLS as a join TABLE_PARAMS as b where a.TBL_ID = b.TBL_ID and TBL_NAME="call_center" and PARAM_KEY="numRows"; +--------+-------------+-----------+-------------+ | TBL_ID | TBL_NAME | PARAM_KEY | PARAM_VALUE | +--------+-------------+-----------+-------------+ | 134 | call_center | numRows | 60 | +--------+-------------+-----------+-------------+2.從HUE上直接查看
總結(jié)
- 上一篇: Excel导出多sheet单sheet通
- 下一篇: 给演讲增色的10种简单方法