Hive學習筆記

2021-08-19 09:26:58 字數 1386 閱讀 1057

beeline可以用!connect jdbc:hive2://localhost:10000 用來連線hiveserver2啟動的hive服務

建表操作

create [external] table [if not exists] table_name

[(col_name data_type [comment col_comment], ...)]

[comment table_comment]

[partitioned by (col_name data_type [comment col_comment], ...)]

[clustered by (col_name, col_name, ...)

[sorted by (col_name [asc|desc], ...)] into num_buckets buckets]

[row format row_format]

[stored as file_format]

[location hdfs_path]

create external  table t_sz_ex(id int,name string) row format delimited field terminated by '\t' stored as textfile location '/sz_ex';  //建立乙個外表

load data local inpath '/andy2.txt' into table t_sz_ex; //使用load名令將資料穿到指定位置

在hive裡面可以直接用命令  dfs -ls 來檢視hadoop中的東西;

刪資料的時候外部表的儲存資料不會被刪除,但是內部表會被刪除

建立 分割槽表

0: jdbc:hive2://localhost:10000> create table t_sz_part(id int,name string)     ng) row format delimited field terminated by '\t' stored as textfile location '/sz_ex';

0: jdbc:hive2://localhost:10000> partitioned by (country string)

0: jdbc:hive2://localhost:10000> row format delimited

0: jdbc:hive2://localhost:10000> fields terminated by ',';

將資料匯入到分割槽表中並且指定分割槽表

0: jdbc:hive2://localhost:10000> load data local inpath '/root/andy2.txt' into table  t_sz_part partition(country=china);

Hive學習筆記 Hive 引數

第一部分 hive 引數 hive.exec.max.created.files 說明 所有hive執行的map與reduce任務可以產生的檔案的和 預設值 100000 hive.exec.dynamic.partition 說明 是否為自動分割槽 預設值 false hive.mapred.re...

Hive學習筆記 Hive概述

1.1 資料倉儲 可以利用資料倉儲來儲存我們的資料,但是資料倉儲有別於我們常見的一般資料庫。資料倉儲是乙個面向主題的 整合的 不可更新的 隨時間不變化的資料整合,它用於支援企業或組織的決策分析處理。物件導向的 倉庫中的資料是按照一定的主題進行組織的。主題即使用者使用資料倉儲進行決策時所關心的重點方面...

hive學習筆記

在使用hive進行開發時,我們往往需要獲得乙個已存在hive表的建表語句 ddl 然而hive本身並沒有提供這樣乙個工具。要想還原建表ddl就必須從元資料入手,我們知道,hive的元資料並不存放在hdfs上,而是存放在傳統的rdbms中,典型的如mysql,derby等,這裡我們以mysql為元資料...