hive入門之內部表和外部表 2

2021-10-02 11:37:52 字數 1362 閱讀 9709

使用建表語句:

使用建表語句:

create table if not exists student2(

id int, name string

)row format delimited fields terminated by '\t'

stored as textfile

location '/user/hive/warehouse/student2';

或者不指定location(注意:如果路徑是在/user/hive/warehouse這個預設的目錄下面還是會被指定為內部表),加上external 關鍵字即可:

檢視表的詳細結構:

因為表是外部表,所以hive並非認為其完全擁有這份資料。刪除該錶並不會刪除掉這份資料,不過描述表的元資料資訊會被刪除掉。也就是說,在刪除內部表的時候其資料和表結構全部沒了,而外部表還會儲存資料在hdfs上面。

將內部表轉化為外部表(後面的false改為true就是將外部表改為內部表):

alter table student2 set tblproperties('external'='true');
其中,external就是附加的意思,附加表為true也就是設定為外部表。

hive內部表與外部表入門

在hive中,表型別主要分為兩種,第一種 內部表 第二種 外部表 create external table tablename id int name string location path 內部表轉外部表 alter table tablename set tblproperties exte...

hive外部表和內部表

1.內部表指hive建立並通過load data inpath進資料庫的表,這種表可以理解為資料和表結構都儲存在一起的資料表。當你通過drop table table name 刪除元資料中表結構的同時,表中的資料也同樣會從hdfs中被刪除。sql view plain copy create ta...

Hive內部表和外部表

總結一下hive的內部表和外部表以及兩者的區別。平時建立的普通表為內部表 create table test internal id string comment id name string comment 名字 comment 測試內部表 row format delimited fields ...