Friday, August 16, 2019

Hive - Create Database

In Hive, the database is considered as a catalog or namespace of tables. So, we can maintain multiple tables within a database where a unique name is assigned to each table. Hive also provides a default database with a name default.
  • Initially, we check the default database provided by Hive. So, to check the list of existing databases, follow the below command: -
  1. hive> show databases;  

Hive Create Database
Here, we can see the existence of a default database provided by Hive.
  • Let's create a new database by using the following command: -
  1. hive> create database demo;  

Hive Create Database
So, a new database is created.


  • Let's check the existence of a newly created database.
  1. hive> show databases;  

Hive Create Database
  • Each database must contain a unique name. If we create two databases with the same name, the following error generates: -
Hive Create Database
  • If we want to suppress the warning generated by Hive on creating the database with the same name, follow the below command: -
  1. hive> create a database if not exists demo;  

Hive Create Database
  • Hive also allows assigning properties with the database in the form of key-value pair.
  1. hive>create the database demo  
  2.         >WITH DBPROPERTIES ('creator' = 'Gaurav Chawla', 'date' = '2019-06-03');   

Hive Create Database
  • Let's retrieve the information associated with the database.
  1. hive> describe database extended demo;  

Hive Create Database

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...