背景:
- 当我们想要删除Hive表中部分符合条件的数据时:
发现Hive表删除数据不能使用\color{red}{不能使用}不能使用DELETE FROM table_name 中SQL语句
解决方案
1.删除符合条件的数据:
其中xxx是你需要保留的数据的查询条件。
insert overwrite table t_table1 select * from t_table1 where XXXX;
示例:
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'
2.删除整个表:
drop table 表名;
如果要永久性删除,不准备再恢复:
drop table 表名 purge;