hive內(nèi)部表、外部表、分區(qū)表、視圖

1、Table 內(nèi)部表

?1).與數(shù)據(jù)庫中的Table在概念上是類似的?

?2).每一個(gè)Table在Hive中都有一個(gè)相應(yīng)的目錄存儲數(shù)據(jù)?

?3).所有的Table數(shù)據(jù)(不包括 External Table) 都保存在這個(gè)目錄中?

?4).刪除表時(shí),元數(shù)據(jù)與數(shù)據(jù)都會被刪除

?5).建表:

??2、Partition 分區(qū)表

?1).Partition 對應(yīng)于數(shù)據(jù)庫的Partition列的密集索引?

?2).在Hive中,表中的一個(gè)Partition對應(yīng)于表下的一個(gè)目錄,所有的Partition的數(shù)據(jù)都存儲在對應(yīng)的目錄中。

?3).建表: hive> create table partition_table > (sid int, sname string) > partitioned by (gender string) > row format delimited fields terminated by ',';

3、External Table 外部表?

?1).指向已經(jīng)在HDFS中存在的數(shù)據(jù),可以創(chuàng)建Partition?

?2).它和內(nèi)部表在元數(shù)據(jù)的組織上是相同的,而實(shí)際數(shù)據(jù)的存儲則有較大的差異?

?3).外部表只有一個(gè)過程,加載數(shù)據(jù)和創(chuàng)建表同時(shí)完成,并不會移動到數(shù)據(jù)庫目錄中,知識與外部數(shù)據(jù)建立一個(gè)連接。當(dāng)刪除一個(gè)外部表時(shí),僅刪除連接。?

?4).建表: hive> create external table external_student > (sid int,sname string,age int) > row format delimited fields terminated by ',' > location '/input';

4、Bucket Table 桶表?

?1). 桶表是對數(shù)據(jù)進(jìn)行哈希取值,值不同的放到不同的文件中存儲。?

?2). 建表: hive> create table bucket_table > (sid int,sname string,age int) > clustered by(sname) into 5 buckets;

5、視圖

1)視圖是一種虛表,是一個(gè)邏輯概念;可以跨越多張表?

2)視圖建立在已有表的基礎(chǔ)上,視圖賴以建立的這些表稱為基表?

3)視圖可以簡化復(fù)雜的查詢?

4)建立視圖: hive> create view empinfo > as > select e.empno,e.ename,e.sal,e.sal*12 annlsal,d.dname > from emp e,dept d > where e.deptno=d.deptno;

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容