Hive使用03 資料庫操作

2021-09-26 14:31:53 字數 946 閱讀 1338

語法:

create (databaseischema) [if not exists] database_name

[comment database comment]

[location hdfs path]

[with dbproperties (property name=property value, ••• )];

舉例:

hive> create database my_hive_testdb if not exists

comment 'this is my first hive database'

with dbproperties (』 creator'=hubert, ' date'='2017-01-01');

切換使用另乙個資料庫的語法如下:

hive> use my_hive_testdb;
檢視所有資料庫的語法如下:

hive > show databases;

刪除指定資料庫的語法如下:

hive > drop database my_hive_testdb; 』

【注意】預設情況下, hive 不允許使用者刪除乙個包含表的資料庫。使用者要麼先刪除資料庫中的

表,再刪除資料庫;要麼在刪除命令的最後加上關鍵字cascade ,這樣hive 會先刪除數

據庫中的表,再刪除資料庫,命令如下(務必謹慎使用此命令):

hive > drop database my_hive_testdb cascade;
檢視資料庫的詳細資訊的語法如下:

hive > describe database my_hive_testdb;

Hive 6 資料庫操作

乙個資料庫對應與檔案系統中的乙個目錄。且他們的根目錄即是 hive.metastore warehouse dir配置項來設定的。比如我這裡就是 user henvealf hive warehouse 剛開始進入 hive 命令行時,預設位於名為 default 的預設資料庫中。其資料目錄就在 u...

實戰 hive 資料庫SQL操作

hive default create database if not exists testdb 檢視所有已建立的資料庫 hive default show databases 匹配查詢資料庫 查詢test開頭,且後續有字元的資料庫 hive default show databaseslike ...

Hive 資料抽象及資料庫操作

ddl data definition language 1 資料抽象 2 資料庫操作 資料庫 包含一系列的表,是對應hdfs上的乙個資料夾,預設是 user hive warehouse 1.建立資料庫 create database schema if not exists database n...