如何列出Hive中所有数据库中所有表中的所有列

时间:2017-11-03 11:07:46

标签: hadoop hive


我需要在我的Hive中的所有数据库中列出所有表中的所有列。

我需要一行,如:

Database.table.column column_type comment

显然我可以使用

show databases;

我可以使用每个数据库

show tables;

并为每个表使用:

describe table_name;

显然我可以使用我的Postgress数据库中某处的Hive_metastore数据库,但我没有访问权限。

但是我希望有一个bash脚本可以遍历数据库 - > tables->列并获取详细信息。

我已经开始生成数据库列表了:

hive -e 'show databases;' | tee databases.txt

比我要遍历数据库并制作表格列表:

#!/bin/bash

for i in `cat databases.txt`;
# w i mamy liste baz
  do
   hive -e 'show tables where database = $i;' | tee tables.txt

done

但我觉得这不是正确的方式...... 你能帮忙吗?

关心
的Pawel

2 个答案:

答案 0 :(得分:0)

替换selectorC

show tables where database = $i。你应该使用use $i; show tables;

但我同意,Metastore将是这里最好的选择

值得一提你的UUOC

Looping through the content of a file in Bash?

答案 1 :(得分:0)

-Xlint:-module
相关问题