hive删除数据(转)

转自:https://www.cnblogs.com/linn/p/6196293.html

按分区删除:

ALTER TABLE test1  DROP PARTITION (dt='2016-04-29');

删除符合条件的数据:

insert overwrite table t_table1 select * from t_table1 where XXXX;

其中xxx是你需要保留的数据的查询条件。

insert overwrite table tlog_bigtable  PARTITION (dt='2017-12-20',game_id = 'id')
select * from tlog_bigtable t
where t.dt = '2017-12-20'
and t.event_time < '2017-12-20 20:00:00'
and t.game_id = 'id'

清空表:

insert overwrite table t_table1 select * from t_table1 where 1=0;

DROP TABLE [IF EXISTS] table_name  ;

TRUNCATE TABLE table_name

原文地址:https://www.cnblogs.com/zuizui1204/p/9504053.html