How to find the number of tables created in a data

2020-05-08 08:26发布

问题:

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

  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

  2. 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