【Hive Partition(分区)DDL操作】

Hive Partition(分区)DDL操作

add partition

ADD PARTITION会更改表元数据,但不会加载数据。如果分区位置中不存在数据,查询时将不会返回结果。

因此需要保证增加的分区位置路径下,数据已经存在,或者增加分区之后导入分区数据。

# 1. 增加分区
alter table table_name add partition (dt='20170101') location
# 一次添加一个分区

alter table table_name 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';
# 一次添加多个分区

rename partition

alter table table_name partition partition_soec rename to partition partition_spec;
alter table table_name partition (dt='2008-08-09') rename to partition (dt='20080809');

delete partition

删除表的分区。这将删除该分区的数据和元数据。

# 删除分区
alter table table_name drop [if exists] partition (dt='2008-08-08', country='us');
# 直接删除数据 不进垃圾桶
alter table table_name drop [if exists] partition (dt='2008-08-08', country='us') purge;

alter partition

# 修改分区
# 更改分区文件存储格式
alter table table_name partition (dt='2008-08-09') set fileformat file_format;
# 更改分区位置
alter table table_name partition (dt='2008-08-09') set location 'new location';
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值