Hive实现删除部分数据 delete from where

Posted 光于前裕于后

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Hive实现删除部分数据 delete from where相关的知识,希望对你有一定的参考价值。

insert overwrite table table_name
select * from table_name where xx;

重写符合条件的数据(与删除条件互斥)

备注:

hive删除表:
drop table table_name;
永久性删除,不能恢复:
drop table table_name purge;

hive删除表中数据:
truncate table table_name;

hive按分区删除数据:
alter table table_name drop partition (partition_name='分区名')

全表:
	1、删除内部表中数据(保留表结构)
	truncate table 表名; 

	2、删除外部表中数据(保留表结构)
	hdfs dfs -rm -r 外部表路径
	drop table 表名;
	
	
表指定数据:
1.分区表
	删除具体partition
	alter table table_name drop partition(partiton_name='分区名');
	
	删除具体partition的部分数据
	INSERT OVERWRITE TABLE table_name PARTITION(year='2021') 
	SELECT * FROM table_name WHERE year='2021' and xx;

2.非分区表
	INSERT OVERWRITE TABLE table_name SELECT * FROM table_name WHERE xx; 

以上是关于Hive实现删除部分数据 delete from where的主要内容,如果未能解决你的问题,请参考以下文章