Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

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

avatar
Explorer
 
1 ACCEPTED SOLUTION

avatar
Contributor

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

View solution in original post

5 REPLIES 5

avatar
Contributor

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

avatar
New Contributor

In this solution, we are able to change position of a single column. Is it possible to change positions of 2 or more consecutive columns in the same way ?

avatar
Super Guru
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?

avatar
Explorer

That's ok

avatar
Contributor

@EricL 

You are right - thank you for pointing this out.