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.
hive> set hive.cli.print.header=true;
hive> select * from tblemployee;
OK
id name gender salary departmentid
1 tomr male 40000 1
2 cats female 30000 2
3 john male 50000 1
4 james male 35000 3
5 sara female 29000 2
6 bens male 35000 1
7 saman female 30000 NULL
8 russel male 40000 2
9 valar female 30000 1
10 todd male 95000 NULL
Time taken: 9.892 seconds
setting the property hive.cli.print.header = true works.
But if you are using a cloudera , HDP or any other distributions, these will be reset. Hence update these value in the Hive configurations and restart the services.
1)Permenant solution
change this property in hive-site.xml file under $HIVE_HOME/conf folder
<property>
<name>hive.cli.print.header</name>
<value>true</value>
<description>Whether to print the names of the columns in query output.
</description>
</property>
2)Temporary solution:
go to hive prompt execute this comman
hive>set hive.cli.print.header=True