hive - how to drop external hive table along with data

amrk7 picture amrk7 · Nov 24, 2012 · Viewed 53.3k times · Source

I am using

drop table <table_name>

If I recreate the table with the same schema and name, I am getting the old data back. Should I remove the table directory from hdfs file system to completely get rid of the data?

Answer

HISI picture HISI · Apr 4, 2018

You have to change the external to internal table before drop it:

example

beeline> ALTER TABLE $tablename SET TBLPROPERTIES('EXTERNAL'='False'); // make the table as internal

and then:

beeline> drop table $tablename; //if you drop the table data will be dropped as well.