In this topic, we described about the Drop Table with detailed example.
Drop table removes/deleted the table. Drop table also removes the underlying HDFS data files for internal tables. Drop table can’t able to delete underlying HDFS data files for external tables.
By default, it removes the associated HDFS directory and data files for the table. The files can’t be deleted if the table was created with the EXTERNAL clause or there is no HDFS location available.
DROP TABLE [IF EXISTS] [db_name.]table_name
The optional IF EXISTS clause makes the statement succeed whether or not the table exists. If the table does exist, it is dropped and if it does not exist, the statement has no effect.
Assume we have a requirement to create student information with the columns student number, name, class, grade for a school.
|Std No||Std Name||Std Class||Std Grade|
std_details table can be dropped by using the below DROP TABLE command.
HCatalog> DROP TABLE IF EXISTS std_db. std_details
On the successful completion of the above statement, the table std_details will be dropped.