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

Nithin K Anil picture Nithin K Anil · Aug 1, 2013 · Viewed 96.5k times · Source

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?

Answer

user2637464 picture user2637464 · Aug 1, 2013

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