如何在Hive中查找在数据库中创建的表的数量? [英] How to find the number of tables created in a database in hive?

查看:103
本文介绍了如何在Hive中查找在数据库中创建的表的数量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要找出在每个架构中创建的表的数量,并找出每个架构所占用的大小.

I need to find out the number of tables created in each schemas and find out the size occupied by each schema.

推荐答案

使用shell脚本可以做到这一点

This is possible to do using shell script

  1. 计算命令输出中的行 hive -S -e设置hive.cli.print.header = false;使用$ schema;显示表;"|wc -l <​​/code>其中$ schema是您的架构名称

  1. Calculate the rows in command output hive -S -e "set hive.cli.print.header=false; use $schema; show tables;" | wc -l Where $schema is your schema name

模式的大小有些棘手.模式中的每个表都可以在HDFS中拥有其自己的位置,该位置与模式默认位置不同.您需要遍历架构表(请参阅上一命令),描述格式化的每个表,解析表位置,获取位置大小并在HDFS中汇总所有表位置大小.要获取表位置的大小,请使用以下命令: hdfs hadoop fs -du [表位置] .

The size of schema is a little bit tricky. Each table in the schema can have it's own location in HDFS that is different from schema default location. You need to loop through schema tables (see previous command), describe formatted each table, parse table location, get location size and sum all table locations size in HDFS. To get table location size use this command: hdfs hadoop fs -du [table location].

这篇关于如何在Hive中查找在数据库中创建的表的数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆