Tom
Tom

Reputation: 6332

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.

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.

Upvotes: 0

Views: 271

Answers (1)

Strick
Strick

Reputation: 1642

There is no such sql command to drop external table directly but there is an alternative

  1. First make this table as managed:
  2. Drop the table

Step 1 :

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

Step 2 :

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

Upvotes: 2

Related Questions