Hive database

The database in Hive describes a collection of tables that are used for a similar purpose or belong to the same groups. If the database is not specified, the default database is used. Whenever a new database is created, Hive creates a directory for each database at /user/hive/warehouse, defined in hive.metastore.warehouse.dir. For example, the myhivebook database is located at /user/hive/datawarehouse/myhivebook.db. However, the default database doesn't have its own directory. The following is the core DDL for Hive databases:

  • Create the database without checking whether the database already exists:
    jdbc:hive2://> CREATE DATABASE myhivebook;
    
  • Create the database and check whether the database already exists:
    jdbc:hive2://> CREATE DATABASE ...

Get Apache Hive Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.