article/hive/hive表删除数据的几种方式.md
2023-09-07 17:25:32 +08:00

746 B
Raw Blame History

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;