Support Questions

Find answers, ask questions, and share your expertise

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

New Contributor
 
1 ACCEPTED SOLUTION

Explorer

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

Explorer

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

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 ?

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?

New Contributor

That's ok

Explorer

@EricL 

You are right - thank you for pointing this out.