I need to find out the number of tables created in each schemas and find out the size occupied by each schema.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
This is possible to do using shell script
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 nameThe 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]
.