hive資料模型之桶表

2021-10-05 12:36:30 字數 720 閱讀 4066

hive的桶表類似於hash分割槽,桶表在hdfs中儲存是以檔案形式儲存的

與其他分割槽表不同,桶表的分割槽條件是從表中列名選取的,然後做hash運算,如果hash值相同那麼就放入乙個桶表中

建立桶表的示例:

create table emp5

(empno int,

ename string,

job string,

mgr int,

hiredate string,

sal int,

comm int,

deptno int)

clustered by (job) into 4 buckets

row format delimited fields terminated by ',';

然後再插入資料(這裡的emp表示我們之前匯入的)

insert into table emp5 select * from emp;

然後我們可以在hdfs中檢視建立的4個桶表

我們也可以使用hdfs命令檢視一下檔案中的內容

至此測試桶表已經完畢

Hive的資料模型 桶表

桶表是對資料進行雜湊取值,然後放到不同檔案中儲存。資料載入到桶表時,會對字段取hash值,然後與桶的數量取模。把資料放到對應的檔案中。物理上,每個桶就是表 或分割槽 目錄裡的乙個檔案,乙個作業產生的桶 輸出檔案 和reduce任務個數相同。桶表專門用於抽樣查詢,是很專業性的,不是日常用來儲存資料的表...

Hive 資料模型

hive 資料模型 hive 資料表有五種型別 內部表,外部表,分割槽表,桶表,檢視表,預設以 tab 分隔 mysql oracle 表預設以逗號分隔,因此,要想匯入 mysql oracle 資料,需要設定分隔符,在建表語句後加 row format delimited fields termi...

Hive筆記 Hive資料模型

hive資料模型 hive中的資料模型主要分為 除了原始列型別 整數integers,浮點數floating point numbers,泛型字串generic strings,日期和布林值dates and booleans 之外,hive還支援陣列 array 和對映 map 此外,使用者可以基...