Hive - Database

> Database > Apache - Hive (HS|Hive Server)

1 - About

All table in hive are in a database.

The database:

  • has a namespaces function
  • are used to enforce security for a user or group of users.
Advertising

3 - Management

3.1 - Set

  • Qualify the table names db_name.table_name
  • or issue the USE statement before the query statement (since Hive 0.6).
USE database_name;
SELECT query_specifications;
USE DEFAULT;

3.2 - Current

SELECT current_database();
default/

3.3 - Describe

DescribeDatabase

DESCRIBE DATABASE [EXTENDED] db_name;
DESCRIBE SCHEMA [EXTENDED] db_name;     -- (Note: Hive 1.1.0 and later)

Example

DESCRIBE DATABASE DEFAULT;
+----------+------------------------+----------------------------+-------------+-------------+-------------+--+
| db_name  |        comment         |          location          | owner_name  | owner_type  | parameters  |
+----------+------------------------+----------------------------+-------------+-------------+-------------+--+
| default  | Default Hive database  | adl://home/hive/warehouse  | public      | ROLE        |             |
+----------+------------------------+----------------------------+-------------+-------------+-------------+--+
Advertising

3.4 - Create

CreateDatabase

CREATE (DATABASE|SCHEMA) [IF NOT EXISTS] database_name
  [COMMENT database_comment]
  [LOCATION hdfs_path]
  [WITH DBPROPERTIES (property_name=property_value, ...)];

3.5 - List / Show

SHOW DATABASES;
db/hive/database.txt · Last modified: 2019/05/16 16:43 by gerardnico