只需从配置表格中获取列名即可 [英] Just get column names from hive table
问题描述
我知道你可以通过hive中的以下技巧从表中获取列名:
hive>设置hive.cli.print.header = true;
hive> select * from tablename;
也可以 从表格中获取列名称?
我不喜欢改变一个我只需要一次的设置。
我目前的解决方案如下:
hive>设置hive.cli.print.header = true;
hive> select * from tablename;
hive>设置hive.cli.print.header = false;
这看起来太冗长而且违背了DRY原则。
如果您只是想查看列名,这一行应该提供它而不更改任何设置:
描述database.tablename;
然而,如果这对你的版本配置单元不起作用,这段代码会提供它,但是你的默认数据库现在将成为您正在使用的数据库:
use database;
描述表名;
I know that you can get column names from a table via the following trick in hive:
hive> set hive.cli.print.header=true;
hive> select * from tablename;
Is it also possible to just get the column names from the table?
I dislike having to change a setting for something I only need once.
My current solution is the following:
hive> set hive.cli.print.header=true;
hive> select * from tablename;
hive> set hive.cli.print.header=false;
This seems too verbose and against the DRY-principle.
If you simply want to see the column names this one line should provide it without changing any settings:
describe database.tablename;
However, if that doesn't work for your version of hive this code will provide it, but your default database will now be the database you are using:
use database;
describe tablename;
这篇关于只需从配置表格中获取列名即可的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!