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 IF NOT EXISTS myhivebook;
Create the database with location, comments, and metadata information:
jdbc:hive2://> CREATE DATABASE IF NOT EXISTS myhivebook . . . . . . .> COMMENT 'hive database demo' . . . . . . .> LOCATION '/hdfs/directory...