hive 外部表 內部表 臨時表

2022-09-08 04:48:10 字數 948 閱讀 6456

1.外部表

關鍵字:external

外部表建立時需要指定location

刪除外部表時,資料不被刪除

create external table page_view(viewtime int, userid bigint,

page_url string, referrer_url string,

ip string comment 'ip address of the user',

country string comment 'country of origination')

comment 'this is the staging page view table'

row format delimited fields terminated by '\054'

stored as textfile

location '';

2.內部表

3.臨時表

hive 0.14.0及以上

表只對當前session有效,session退出後,表自動刪除。

語法:

create temporary table ...
注意點:

1、如果建立的臨時表表名已存在,那麼當前session引用到該錶名時實際用的是臨時表,只有drop或rename臨時表名才能使用原始表

2、臨時表限制:不支援分割槽欄位和建立索引

hive1.1開始臨時表可以儲存在記憶體或ssd,使用hive.exec.temporary.table.storage引數進行配置,該引數有三種取值:memory、ssd、default。

Hive內部表 外部表

內部表 外部表 未被external修飾的是內部表 managed table 被external修飾的為外部表 external table 區別 內部表資料由hive自身管理,外部表資料由hdfs管理 內部表資料儲存的位置是hive.metastore.warehouse.dir 預設 user...

hive外部表和內部表

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

Hive內部表 外部表區別

hive內部表 外部表區別自不用說,可實際用的時候還是要小心。1.內部表 sql view plain copy print create table tt name string age string location input table data 此時,會在hdfs上新建乙個tt表的資料存放...