746 B
746 B
hive 删除数据
删除表
-- hive删除表:
drop table table_name;
-- 永久性删除,不能恢复:
drop table table_name purge;
清空数据
-- hive删除表中数据:
truncate table table_name;
-- hive按分区删除数据:
alter table table_name drop partition (partition_name='分区名')
重写数据
与删除条件相反,如删除 date=0528 的数据
那么 重写数 的条件为 date!=0528
分区表
删除具体partition的部分数据
INSERT OVERWRITE TABLE table_name PARTITION(year='2021')
SELECT * FROM table_name WHERE year='2021' and xx;
非分区表
INSERT OVERWRITE TABLE table_name SELECT * FROM table_name WHERE xx;