是否可以通过与Hive类似的方式通过Hive在单个命令中捕获所有模式+表名信息SELECT * FROM information_schema.tables
来自PostgreSQL世界?
一个循环中的show databases
和show tables
组合在一起[示例]是一个答案,但是我正在寻找一种更紧凑的方法来在单个命令中获得相同的结果。
最佳答案
我从事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(元存储)引入有关数据库的元数据。
关于hadoop - 配置单元一行命令以捕获SCHEMA + TABLE NAME信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62041576/