大資料學習 hive基本操作

2022-03-21 22:17:29 字數 2082 閱讀 6245

1 建表

create

table student(id int,name string ,age int)

row format delimited

fields terminated by ',';

2 建立乙個student.txt

新增資料

1,zhangsan,10

2,lisi,20

3,wnagwu,25

3 上傳

5 通常不會通過put方式載入資料,而是通過load的方式新增資料

6 新增hdfs上的資料到hive

7 內部表和外部表的區別

external關鍵字可以讓使用者建立乙個外部表,在建表的同時指定乙個指向實際資料的路徑(location),hive 建立內部表時,會將資料移動到資料倉儲指向的路徑;若建立外部表,僅記錄資料所在的路徑,不對資料的位置做任何改變。在刪除表的時候,內部表的元資料和資料會被一起刪除,而外部表只刪除元資料,不刪除資料。

企業開發中經常使用的是外部表,刪除表後,元資料還在,比較安全

8 建立乙個分割槽表

create

table t_partitioned(ip string ,duration int

)partitioned

by(country string)

row format delimited

fields terminated by'

,';

9 造資料

10 資料儲存格式

stored as

sequencefile|textfile|rcfile

如果檔案資料是純文字,可以使用 stored as textfile。如果資料需要壓縮,使用 stored as sequencefile。

create

table t_3(id int

,name string)

row format delimited

fields terminated by'

,'stored

as sequencefile;

插入資料(不能用load方式新增資料)

insert overwrite table t_3 select id,name from student;

大資料學習之Hive

建立乙個自定義列表 如何建立乙個註腳 注釋也是必不可少的 katex數學公式 新的甘特圖功能,豐富你的文章 uml 圖表 flowchart流程圖 匯出與匯入 1 hive處理的資料儲存在hdfs 2 hive分析資料底層的實現是mapreduce 3 執行程式執行在yarn上 hive的優缺點 帶...

大資料學習(二) python3操作hive

使用python3操作hive需要簡單的幾個步驟 操作環境 linux pip install sasl pip install thrift pip install thrift sasl pip install pyhive 安裝過程中,在安裝sasl的時候可能會出現 缺少sasl.h 的錯誤,...

hive基本操作

1.顯示所有資料庫 show databases 2.使用某個資料庫 use xx xx表示某個資料庫名 3.顯示某資料庫下的所有表 show tables 4.檢視表結構 顯示各欄位 desc 表名 5.資料匯出到本地 在hive中操作 insert overwrite local directo...