Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to get the column name along with the output while execute any query in Hive?

Tags:

hadoop

rdbms

hive

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?

like image 978
Nithin K Anil Avatar asked Aug 01 '13 05:08

Nithin K Anil


People also ask

How do I find a column name in Hive?

select TBL_NAME, COLUMN_NAME, TYPE_NAME from TBLS left join COLUMNS_V2 on CD_ID = TBL_ID where COLUMN_NAME like 'column'; where 'column' is the column name you're looking for.

How do I select columns in Hive?

The easiest way to select specific columns in the Hive query is by specifying the column name in the select statement. SELECT col1, col3, col4 .... FROM Table1; But imagine your table contains many columns (i.e : more than 100 columns) and you need to only exclude a few columns in the select statement.


1 Answers

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; 

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

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

like image 120
user2637464 Avatar answered Sep 18 '22 19:09

user2637464