Hive對資料庫database的建立、修改
阿新 • • 發佈:2019-01-03
前言:Hive中對database的建立、查詢、location、修改、刪除等操作,作了簡單描述
1.建立資料庫
hive>create database myhive;
hive>create database if not exists myhive;
2.查詢資料庫和表
hive>show databases;
hive>show tables;
使用正則表示式:
hive>show databases like 'h.*';
3.修改資料庫預設位置
hive>create database myhive
>location 'my/myhive.db'; //要指定資料庫名
1)為資料庫增加描述資訊
hive>create database myhive
>comment 'this is my';
hive> desc database myhive; //顯示詳細資訊
2)增加一些和其相關的鍵-值對屬性資訊
hive>create database myhive
>with dbproperties('name'='lu','data'='2012-01-02');
檢視:hive>desc database extended
hive>use default;
3)刪除資料庫
hive>drop database if exists myhive; //避免資料庫不存在而丟擲警告資訊
如果資料庫下有表,就不允許刪除;要是刪除的話,則:
hive>drop database if exists myhive cascade;
restrict(預設)不允許刪除;
4.修改資料庫
為資料庫的dbproperties設定鍵值對屬性值,來描述資料庫屬性資訊,
資料庫其他元資料都是不可更改的,包括資料庫名和資料庫所在目錄位置
hive>alter database myhive set dbproperties