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.
Articles Related
Management
Set
- Qualify the table names db_name.table_name
- Set it in the Uri
- or issue the USE statement before the query statement (since Hive 0.6).
USE database_name;
SELECT query_specifications;
USE default;
Current
SELECT current_database();
default/
Describe
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 | |
+----------+------------------------+----------------------------+-------------+-------------+-------------+--+
Create
CREATE (DATABASE|SCHEMA) [IF NOT EXISTS] database_name
[COMMENT database_comment]
[LOCATION hdfs_path]
[WITH DBPROPERTIES (property_name=property_value, ...)];
List / Show
show databases;