Reply
Highlighted
New Contributor
Posts: 4
Registered: ‎04-23-2019
Accepted Solution

How can we change the column order in Hive table without deleting data.

 
Explorer
Posts: 15
Registered: ‎11-23-2017

Re: How can we change the column order in Hive table without deleting data.

Hi,

 

This command moves column_name after column_name2:

alter table table_name change column column_name column_name column_name_type after column_name2;

 

You have to put the column_name twice (or you can change column name) and type of the column.

 

Regards

Andrzej

Cloudera Employee
Posts: 724
Registered: ‎03-23-2015

Re: How can we change the column order in Hive table without deleting data.

If you change column order, it will affect existing data, so the new position of the column will match different data, that's OK for you?
New Contributor
Posts: 4
Registered: ‎04-23-2019

Re: How can we change the column order in Hive table without deleting data.

That's ok

Explorer
Posts: 15
Registered: ‎11-23-2017

Re: How can we change the column order in Hive table without deleting data.

[ Edited ]

@EricL 

You are right - thank you for pointing this out.