Friday, August 16, 2019

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: -
  1. hive> show databases;  

Hive Drop Database
  • Now, drop the database by using the following command.
  1. hive> drop database demo;  

Hive Drop Database
  • Let's check whether the database is dropped or not.
  1. hive> show databases;  

Hive Drop Database
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:
Hive Drop Database
  • However, if we want to suppress the warning generated by Hive on creating the database with the same name, follow the below command:-
  1. hive> drop database if exists demo;  
Hive Drop Database
  • 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:-
  1. hive> drop database if exists demo cascade;  
This command automatically drops the tables present in the database first.


No comments:

Post a Comment

Lab 09: Publish and subscribe to Event Grid events

  Microsoft Azure user interface Given the dynamic nature of Microsoft cloud tools, you might experience Azure UI changes that occur after t...