hive里如何快速查看表中有多少记录数

来源:互联网 发布:win10 预装软件 编辑:程序博客网 时间:2024/06/07 13:58

方法一:

在hue界面的hive下找到相应的表,即可看到表的行数和大小等信息。



方法二编写脚本,


[root@namenode01 hive]# cat count_tables.sh 

myorder=1
while read line;
do
eval "hive --database tpc_ds -S -e 'select \"$myorder\" as myorder, \"$line\" as tablename, count(*) as rowcount from $line;' &"
myorder=$(($myorder+1));
done;
[root@namenode01 hive]# cat tables.txt 
call_center

执行脚本
sh count_tables.sh  tables.txt 

三种情况 直接从Mysql里查询

mysql> use hive

select * from TBLS where TBL_NAME='call_center';

mysql> 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="web_sales" and PARAM_KEY="numRows";
+--------+-----------+-----------+-------------+
| TBL_ID | TBL_NAME  | PARAM_KEY | PARAM_VALUE |
+--------+-----------+-----------+-------------+
|    382 | web_sales | numRows   | -1          |
|    406 | web_sales | numRows   | 144002668   |
+--------+-----------+-----------+-------------+