2016-01-25 98 views
1

我在找Hive中的所有表定義。我知道,對於單表的定義我可以使用類似 -如何獲取Hive數據庫中的所有表定義?

describe <<table_name>> 
    describe extended <<table_name>> 

但是,我無法找到一個辦法讓所有的表定義。在megastore中是否有類似於MySQL中的Information_Schema的表或者是否有命令來獲取所有表定義?

+0

另一個可疑類似於http://stackoverflow.com/questions/35005191/query-hive-meta-store/35012810的問題 –

回答

4

你可以通過編寫一個簡單的bash腳本和一些bash命令來做到這一點。

首先,寫在一個數據庫中的所有表名用一個文本文件:此列表中

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

然後創建一個bash腳本(describe_tables.sh)遍歷每個表:

while read line 
do 
echo "$line" 
eval "hive -e 'describe <dbname>.$line'" 
done 

然後執行該腳本:

$chmod +x describe_tables.sh 
$./describe_tables.sh <tables.txt> definitions.txt 

的definitions.txt文件將包含所有的表defini蒸發散。

相關問題