当前位置:   article > 正文

hive查看数据库里库的信息_如何获取Hive数据库中的所有表定义?

hive查看数据库里库的信息_如何获取Hive数据库中的所有表定义?

I am looking to get all table definitions in Hive. I know that for single table definition I can use something like -

describe <>

describe extended <>

But, I couldn't find a way to get all table definitions. Is there any table in megastore similar to Information_Schema in mysql or is there command to get all table definitions ?

解决方案

You can do this by writing a simple bash script and some bash commands.

First, write all table names in a database to a text file using:

$hive -e 'show tables in ' | tee tables.txt

Then create a bash script (describe_tables.sh) to loop over each table in this list:

while read line

do

echo "$line"

eval "hive -e 'describe .$line'"

done

Then execute the script:

$chmod +x describe_tables.sh

$./describe_tables.sh < tables.txt > definitions.txt

The definitions.txt file will contain all the table definitions.

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/神奇cpp/article/detail/969527
推荐阅读
相关标签
  

闽ICP备14008679号