答案 0 :(得分:0)
如果您想通过查询进行操作。
insert overwrite table <tablename>
select
col1,
col2,
....
from tablename where timekey >(select from_unixtime(unix_timestamp(add_months(current_date(),-3), 'yyyy-MM-dd'), 'yyyyMM'));
以上查询将读取表数据并仅插入最近3个月的记录
答案 1 :(得分:0)
就删除更新而言,Hive不支持此类操作,但支持新的Hive版本事务。但是您需要为此创建事务配置单元表。
下面是创建此交易表时可以使用的语法,
CREATE TABLE hello_acid (key int, value int)
PARTITIONED BY (load_date date)
CLUSTERED BY(key) INTO 3 BUCKETS
STORED AS ORC TBLPROPERTIES ('transactional'='true');
您可以参考下面的链接以获取更多详细信息, https://hortonworks.com/tutorial/using-hive-acid-transactions-to-insert-update-and-delete-data/
希望这会有所帮助。