Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

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

Solved Go to solution
Highlighted

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

New Contributor
 
1 ACCEPTED SOLUTION

Accepted Solutions

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

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

4 REPLIES 4

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

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

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

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?

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

New Contributor

That's ok

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

Explorer

@EricL 

You are right - thank you for pointing this out.

Don't have an account?
Coming from Hortonworks? Activate your account here