75
Hive – Drop Database
In this section, we will see various ways to drop the existing database.
- Let’s check the list of existing databases by using the following command: –
- Now, drop the database by using the following command.
- Let’s check whether the database is dropped or not.
As we can see, the database demo is not present in the list. Hence, the database is dropped successfully.
- If we try to drop the database that doesn’t exist, the following error generates:
- However, if we want to suppress the warning generated by Hive on creating the database with the same name, follow the below command:-
- In Hive, it is not allowed to drop the database that contains the tables directly. In such a case, we can drop the database either by dropping tables first or use Cascade keyword with the command.
- Let’s see the cascade command used to drop the database:-
This command automatically drops the tables present in the database first.
Next TopicHive Create Table