Hive Alter table change Column Name

user2978621 picture user2978621 · Feb 26, 2014 · Viewed 127k times · Source

I am trying to rename a columnName in Hive. Is there a way to rename column name in Hive .

tableA (column1 ,_c1,_c2) to tableA(column1,column2,column3) ??

Answer

Remus Rusanu picture Remus Rusanu · Feb 26, 2014

Change Column Name/Type/Position/Comment:

ALTER TABLE table_name CHANGE [COLUMN] col_old_name col_new_name column_type [COMMENT col_comment] [FIRST|AFTER column_name]

Example:

CREATE TABLE test_change (a int, b int, c int);

// will change column a's name to a1
ALTER TABLE test_change CHANGE a a1 INT;