是否可以通过Hive以与
相似的方式通过Hive捕获所有模式+表名信息SELECT * FROM information_schema.tables
来自PostgreSQL世界?
show databases
和show tables
组合成一个循环 [here是一个答案],但我正在寻找一种更紧凑的方法,以便在单个命令中获得相同的结果。
答案 0 :(得分:0)
我从事Hive查询已经很久了,但据我所知,您可能可以使用
hive> desc formatted tableName;
或
hive> describe formatted tableName;
它将为您提供与表相关的所有相关信息,例如模式,分区信息,表类型(例如托管表等)
我不确定您是否正在寻找这个?
查询Hive表的另一种方法是编写Hive脚本,可以从Hadoop Terminal而不是从Hive Terminal本身调用它。
std]$ cat sample.hql or vi sample.hql
use dbName;
select * from tableName;
desc formatted tableName;
# this hql script can be called from outside the hive terminal
std]$ hive -f sample.hql
或者,甚至不必编写脚本文件,您就可以将蜂巢查询为
std]$ hive -e "use dbName; select * from emp;" > text.txt or >> to append
在数据库级别,您可能可以查询为:
hive> use dbName;
hive> set hive.cli.print.current.db=true;
hive(dbName)> describe database dbName;
它将从MySQL(元存储)中获取有关数据库的元数据。