Get row count from all tables in hive

2020-07-10 08:31发布

How can I get row count from all tables using hive? I am interested in the database name, table name and row count

标签: hql hive
8条回答
Melony?
2楼-- · 2020-07-10 09:21

How do I mention the specific database that it needs to refer in below snippet:

while read line
do
 echo "$line "
 eval "hive -e 'select count(*) from $line'"
done
查看更多
姐就是有狂的资本
3楼-- · 2020-07-10 09:23

A much faster way to get approximate count of all rows in a table is to run explain on the table. In one of the explain clauses, it shows row counts like below:

TableScan [TS_0] (rows=224910 width=78)

The benefit is that you are not actually spending cluster resources to get that information.


The HQL command is explain select * from table_name; but when not optimized not shows rows in the TableScan.

查看更多
登录 后发表回答