hive 分区查看新增及删除

本文详细介绍如何使用SQL进行数据分区管理,包括查看、添加、删除分区,以及清空表和删除特定数据的方法。适用于需要对大数据集进行高效管理和优化查询性能的场景。

查看表现有分区:

show partitions table_name;

查看分区:

show partitions tableName;

获取最新分区(day):

select max(day) as latest_day from table

添加分区(分区字段包含:p_hour,p_city,p_loctype。):

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

--  删除库
drop database if exists db_name;
--  强制删除库
drop database if exists db_name cascade;

--  删除表
drop table if exists employee;

--  清空表
truncate table employee;
--  清空表,第二种方式
insert overwrite table employee select * from employee where 1=0;

--  删除分区
alter table employee_table drop partition (stat_year_month>='2018-01');

--  按条件删除数据
insert overwrite table employee_table select * from employee_table where id>'180203a15f';
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值