Hive:添加、删除分区

添加分区:

alter table my_partition_test_table if not exists add partition (p_hour='2017113003', p_city='573', p_loctype='MHA');

已经创建好的分区表:

INFO  :         Loading partition {p_hour=2017113003, p_city=573, p_loctype=MHA}
INFO  :         Loading partition {p_hour=2017113019, p_city=579, p_loctype=MHA}
INFO  :         Loading partition {p_hour=2017113010, p_city=574, p_loctype=MHA}
INFO  :         Loading partition {p_hour=2017113012, p_city=575, p_loctype=MHA}
INFO  :         Loading partition {p_hour=2017113013, p_city=572, p_loctype=MHA}
INFO  :         Loading partition {p_hour=2017113018, p_city=571, p_loctype=MHA}
INFO  :         Loading partition {p_hour=2017113006, p_city=571, p_loctype=MHA}
INFO  :         Loading partition {p_hour=2017113007, p_city=580, p_loctype=MHA}

分区字段包含:p_hour,p_city,p_loctype。

根据分区字段p_loctype删除分区:

ALTER TABLE my_partition_test_table DROP IF EXISTS PARTITION (p_loctype='MHA');

删除日志:

INFO  : Dropped the partition p_hour=2017113001/p_city=574/p_loctype=MHA
INFO  : Dropped the partition p_hour=2017113001/p_city=577/p_loctype=MHA
INFO  : Dropped the partition p_hour=2017113001/p_city=579/p_loctype=MHA
INFO  : Dropped the partition p_hour=2017113002/p_city=570/p_loctype=MHA

 

posted @ 2017-12-21 14:53  cctext  阅读(95424)  评论(2编辑  收藏  举报