文章目录
show partitions iteblog; |
ALTER TABLE table_name ADD [IF NOT EXISTS] PARTITION partition_spec [LOCATION ‘location1‘] partition_spec [LOCATION ‘location2‘] ...; partition_spec: : (partition_column = partition_col_value, partition_column = partition_col_value, ...)ALTER TABLE iteblog ADD PARTITION (dt=‘2008-08-08‘) location ‘/path/to/us/part080808‘;ALTER TABLE iteblog ADD PARTITION (dt=‘2008-08-08‘, country=‘us‘) location ‘/path/to/us/part080808‘;ALTER TABLE iteblog ADD PARTITION (dt=‘2008-08-08‘, country=‘us‘) location ‘/path/to/us/part080808‘ PARTITION (dt=‘2008-08-09‘, country=‘us‘) location ‘/path/to/us/part080809‘; |
ALTER TABLE table_name DROP [IF EXISTS] PARTITION partition_spec[, PARTITION partition_spec, ...]ALTER TABLE iteblog DROP PARTITION (dt=‘2008-08-08‘, country=‘us‘); |
ALTER TABLE iteblog PARTITION (dt=‘2008-08-08‘) SET LOCATION "new location";ALTER TABLE iteblog PARTITION (dt=‘2008-08-08‘) RENAME TO PARTITION (dt=‘20080808‘); |
ALTER TABLE iteblog ADD COLUMNS (col_name STRING); |
CREATE TABLE iteblog (a int, b int, c int);// will change column a‘s name to a1ALTER TABLE iteblog CHANGE a a1 INT; // will change column a‘s name to a1, a‘s data type to string, and put it after column b. The new table‘s structure is: b int, a1 string, c intALTER TABLE iteblog CHANGE a a1 STRING AFTER b; // will change column b‘s name to b1, and put it as the first column. The new table‘s structure is: b1 int, a string, c intALTER TABLE iteblog CHANGE b b1 INT FIRST; |
ALTER TABLE iteblog RENAME TO new_table_name |
参考:https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-AddPartitions
原文:https://www.cnblogs.com/shujuxiong/p/10395919.html