如何在Hive中截断分区的外部表?

问题描述:

我打算截断具有一个分区的配置单元外部表.因此,我已使用以下命令截断该表:

I'm planning to truncate the hive external table which has one partition. So, I have used the following command to truncate the table :

 hive> truncate table abc; 

但是,它抛出了一个错误提示:无法截断非托管表abc.

But, it is throwing me an error stating : Cannot truncate non-managed table abc.

有人可以建议我就同一件事...

Can anyone please suggest me out regarding the same ...

首先创建表MANAGED:

ALTER TABLE abc SET TBLPROPERTIES('EXTERNAL'='FALSE');

然后截断:

truncate table abc;

最后,您可以再次将其设置为外部:

And finally you can make it external again:

ALTER TABLE abc SET TBLPROPERTIES('EXTERNAL'='TRUE');