gpt4 book ai didi

hadoop - 更改表分区

转载 作者:行者123 更新时间:2023-12-02 20:08:18 26 4
gpt4 key购买 nike

我有一个带分区的表。我已将数据加载到该表中。现在,
是否可以从该表中删除分区,而又不删除已加载的数据?

最佳答案

是。您可以创建具有相同架构的第二个表,并将空表换出当前分区。

-- create tables
CREATE TABLE t1 (a string, b string) partitioned by (ds string);
CREATE TABLE t2 (a string, b string);

-- then swap partitions
ALTER TABLE t1 EXCHANGE PARTITION (ds = '1') WITH TABLE t2;

另一种方法是创建一个新的空分区:
ALTER TABLE sales
PARTITION (country = 'US', year = 2012, month = 12, day = 22)
SET LOCATION = 'sales/partitions/us/2012/12/22' ;

无论采用哪种方法,您的数据仍然会存在。我不久前写了一个 introduction to hive partitioning应该会有所帮助。

关于hadoop - 更改表分区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19853640/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com