Dropping Table


Dropping Table

This post descibes, how to drop a table in HCatalog. When you drop a table from the metastore, it removes the table/column data and their metadata. It can be a normal table (stored in metastore) or an external table (stored in local file system); HCatalog treats both in the same manner, irrespective of their types.

Step 1 - Open a new terminal (CTRL + ALT + T) and Change the directory to /usr/local/hive/hcatalog/bin




$ cd $HCAT_HOME/bin

Step 2 - Creating a new employee table




$ ./hcat -e "CREATE TABLE IF NOT EXISTS employee( eid int, name String, salary String, destination String) \
COMMENT 'Employee details' \
ROW FORMAT DEIMITED \
FIELDS TERMINATED BY ' ' \
LINES TERMINATED BY '\n' \
STORED AS TEXTFILE;"


Step 3 - Check whether it is created or not. It shows all the tables that are present.




$ ./hcat -e "show tables;"

Step 4 - Dropping Table




$ ./hcat -e "DROP TABLE IF EXISTS employee;"

Step 5 - Check whether it is dropped or not. It shows all the tables that are present.




$ ./hcat -e "show tables;"

Have any Question or Comment?

Leave a Reply

Your email address will not be published. Required fields are marked *