用一行命令捕获SCHEMA +表名信息

问题描述 投票:1回答:1

是否有一种方法可以通过Hive来捕获所有schema +表名信息在单个命令中,类似于

SELECT *  FROM information_schema.tables

来自PostgreSQL世界?

show databasesshow tables组合在一个循环 [here中]是一个答案,但我正在寻找一种更紧凑的方法来在单个命令中获得相同的结果。

hadoop hive database-schema database-table
1个回答
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(元商店)带来有关数据库的元数据。

© www.soinside.com 2019 - 2024. All rights reserved.