Gol*_*num 4 hadoop hive bigdata
我希望在Hive中获取所有表定义.我知道对于单表定义我可以使用类似的东西 -
describe <<table_name>>
describe extended <<table_name>>
Run Code Online (Sandbox Code Playgroud)
但是,我找不到获取所有表定义的方法.在megastore中是否有类似于mysql中的Information_Schema的表,或者是否有命令来获取所有表定义?
小智 13
您可以通过编写简单的bash脚本和一些bash命令来完成此操作.
首先,使用以下方法将数据库中的所有表名写入文本文件:
$hive -e 'show tables in <dbname>' | tee tables.txt
Run Code Online (Sandbox Code Playgroud)
然后创建一个bash脚本(describe_tables.sh)来循环遍历此列表中的每个表:
while read line
do
echo "$line"
eval "hive -e 'describe <dbname>.$line'"
done
Run Code Online (Sandbox Code Playgroud)
然后执行脚本:
$chmod +x describe_tables.sh
$./describe_tables.sh < tables.txt > definitions.txt
Run Code Online (Sandbox Code Playgroud)
definitions.txt文件将包含所有表定义.
归档时间: |
|
查看次数: |
25628 次 |
最近记录: |