如何在不删除数据的情况下撤消ALTER TABLE ... ADD PARTITION [英] How to undo ALTER TABLE ... ADD PARTITION without deleting data
本文介绍了如何在不删除数据的情况下撤消ALTER TABLE ... ADD PARTITION的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有两个配置单元表, table_1
和 table_2
.我使用:
Let's suppose I have two hive tables, table_1
and table_2
. I use:
ALTER TABLE table_2 ADD PARTITION (col=val) LOCATION [table_1_location]
现在, table_2
将在 col = val
的分区中将数据存储在 table_1
中.
Now, table_2
will have the data in table_1
at the partition where col = val
.
我想做的就是逆转此过程.我希望 table_2
不在 col = val
上具有分区,并且我希望table_1保留其原始数据.
What I want to do is reverse this process. I want table_2
not to have the partition at col=val
, and I want table_1 to keep its original data.
我该怎么做?
推荐答案
首先将表设为EXTERNAL:
Make your table EXTERNAL first:
ALTER TABLE table_2 SET TBLPROPERTIES('EXTERNAL'='TRUE');
然后放置分区,数据将保留,仅table_2分区元数据将被删除:
Then drop partition, the data will remain, only table_2 partition metadata will be deleted:
ALTER TABLE table_2 DROP PARTITION (col=val)
table_1分区数据将保持不变.
table_1 partition data will remain as is.
这篇关于如何在不删除数据的情况下撤消ALTER TABLE ... ADD PARTITION的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文