Hive Table Change Column Name/Type/Position/Comment

 

Example:

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

// First change column a's name to a1.

ALTER TABLE test_change CHANGE a a1 INT;

// Next change column a1's name to a2, its data type to string, and put it after column b.

ALTER TABLE test_change CHANGE a1 a2 STRING AFTER b;

// The new table's structure is:  b int, a2 string, c int.

// Then change column c's name to c1, and put it as the first column.

ALTER TABLE test_change CHANGE c c1 INT FIRST;

// The new table's structure is:  c1 int, b int, a2 string.

// Add a comment to column a1

ALTER TABLE test_change CHANGE a1 a1 INT COMMENT 'this is column a1';

您可以选择一种方式赞助本站