简体   繁体   English

是否有 sql 命令删除外部表的 HDFS 上的文件

[英]Is there a sql command to delete the files on HDFS for an external table

I would ask if there is a sql command in hive to drop the table and delete the files on hdfs for this external table.我会问在 hive 中是否有 sql 命令来删除该表并删除 hdfs 上此外部表的文件。

When I use hdfs command to delete the files, I am always afraid that I may delete other files that doesn't belong to this external table.当我使用 hdfs 命令删除文件时,我总是害怕我可能会删除不属于这个外部表的其他文件。

There is no such sql command to drop external table directly but there is an alternative没有这样的 sql 命令可以直接删除外部表,但有另一种选择

  1. First make this table as managed:首先将此表设为托管:
  2. Drop the table放下桌子

Step 1:步骤1:

ALTER TABLE <table-name> SET TBLPROPERTIES('EXTERNAL'='False');

Step 2:第2步:

 drop table <table-name>; //now the table is internal if you drop the table data will be dropped automatically.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM