Amol Fasale
Amol Fasale

Reputation: 942

How to delete/truncate tables from Hadoop-Hive?

Please tell me how to delete table from hive and also tell from where i can get more information about hive queries.

Upvotes: 25

Views: 170332

Answers (3)

Anoop Velluva
Anoop Velluva

Reputation: 329

To Truncate:

hive -e "TRUNCATE TABLE IF EXISTS $tablename"

To Drop:

hive -e "Drop TABLE IF EXISTS $tablename"

Upvotes: 12

Balaswamy Vaddeman
Balaswamy Vaddeman

Reputation: 8540

You can use drop command to delete meta data and actual data from HDFS.

And just to delete data and keep the table structure, use truncate command.

For further help regarding hive ql, check language manual of hive.

Upvotes: 31

Abimaran Kugathasan
Abimaran Kugathasan

Reputation: 32488

Use the following to delete all the tables in a linux environment.

hive -e 'show tables' | xargs -I '{}' hive -e 'drop table {}'

Upvotes: 6

Related Questions