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

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


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


To print header along with the output, the following hive conf property should be set to true before executing the query.

hive> set hive.cli.print.header=true;hive> select * from table_name;

We can also use query like this, if we want to get result in file.

hive -e 'set hive.cli.print.header=true;select * from table_name;' > result.xls

Where table_name your table name


All above answers already answer the question. But in case if someone wants this property to be ON permanently, then there is this property: hive.cli.print.header in hive-default.xml or hive-site.xml.

Its default value is false. Make its value as true and save.Done.