溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

Hive中DDL數(shù)據(jù)定義的示例分析

發(fā)布時間:2021-12-10 14:30:52 來源:億速云 閱讀:125 作者:小新 欄目:大數(shù)據(jù)

這篇文章主要介紹了Hive中DDL數(shù)據(jù)定義的示例分析,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。

##數(shù)據(jù)庫
####創(chuàng)建數(shù)據(jù)庫
創(chuàng)建一個數(shù)據(jù)庫,數(shù)據(jù)庫在HDFS上的默認(rèn)存儲路徑是/user/hive/warehouse/*.db。

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

創(chuàng)建表

hive (default)> create database db_hive;

避免要創(chuàng)建的數(shù)據(jù)庫已經(jīng)存在錯誤,增加if not exists判斷

hive (default)> create database db_hive;FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. Database db_hive already existshive (default)> create database if not exists db_hive;OKTime taken: 0.024 seconds

查看數(shù)據(jù)HDFS存儲位置

hive (default)> dfs -ls /user/hive/warehouse;

指定數(shù)據(jù)庫存儲位置

hive (default)> create database db_hive2 location '/db_hive2.db';

顯示數(shù)據(jù)庫信息

hive (default)> desc database db_hive;OKdb_name comment location  owner_name  owner_type  parametersdb_hive   hdfs://localhost:9000/user/hive/warehouse/db_hive.db  baxiang USERTime taken: 0.061 seconds, Fetched: 1 row(s)

顯示數(shù)據(jù)庫

hive (default)> show databases;OKdatabase_namedb_hivedb_hive2defaultTime taken: 0.04 seconds, Fetched: 3 row(s)

感謝你能夠認(rèn)真閱讀完這篇文章,希望小編分享的“Hive中DDL數(shù)據(jù)定義的示例分析”這篇文章對大家有幫助,同時也希望大家多多支持億速云,關(guān)注億速云行業(yè)資訊頻道,更多相關(guān)知識等著你來學(xué)習(xí)!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI