在 Hive 中执行任何查询时,有没有办法获取列名和输出? [英] Is there any way to get the column name along with the output while execute any query in Hive?

查看:22
本文介绍了在 Hive 中执行任何查询时,有没有办法获取列名和输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Hive 中,当我们执行查询(例如:select * from employee)时,我们不会在输出中得到任何列名(例如我们将在 RDBMS SQL),我们只得到值.

In Hive, when we do a query (like: select * from employee), we do not get any column names in the output (like name, age, salary that we would get in RDBMS SQL), we only get the values.

当您执行任何查询时,有没有办法让列名与输出一起显示?

Is there any way to get the column names to be displayed along with the output when you execute any query?

推荐答案

如果我们想在 HiveQl 中看到表的列名,应该将下面的 hive conf 属性设置为 true.

If we want to see the columns names of the table in HiveQl, the following hive conf property should be set to true.

hive> set hive.cli.print.header=true;

如果您希望始终看到列名,请在第一行中使用上述设置更新 $HOME/.hiverc 文件..

If you prefer to see the column names always then update the $HOME/.hiverc file with the above setting in the first line..

--Hive 会自动在您的 HOME 目录中查找名为 .hiverc 的文件并运行其中包含的命令(如果有)

--Hive automatically looks for a file named .hiverc in your HOME directory and runs the commands it contains, if any

这篇关于在 Hive 中执行任何查询时,有没有办法获取列名和输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆