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

xiaoxiao2021-02-28  103

方法一:

在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   | +--------+-----------+-----------+-------------+
转载请注明原文地址: https://www.6miu.com/read-53677.html

最新回复(0)