Please tell me how to delete table from hive and also tell from where i can get more information about hive queries.
DROP TABLE command in the hive is used to drop a table inside the hive. Hive will remove all of its data and metadata from the hive meta-store. The hive DROP TABLE statement comes with a PURGE option.
Truncating a table in Hive is indirectly removing the files from the HDFS as a table in Hive is just a way of reading the data from the HDFS in the table or structural format. The general format of using the Truncate table command is as follows: TRUNCATE TABLE table_name [PARTITION partition_spec];
You cannot delete or truncate an external table. However, you can alter and drop the table definition. Dropping an external table drops the table definition, but it does not delete the data file that is associated with the table.
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.
To Truncate:
hive -e "TRUNCATE TABLE IF EXISTS $tablename"
To Drop:
hive -e "Drop TABLE IF EXISTS $tablename"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With