hive hive 內部表和外部表

2021-09-07 11:45:44 字數 2132 閱讀 3469

1.內部表

hive (test1)>create table com_inner_person(id

int,name string,age int,ctime timestamp) row format delimited fields terminated by '

,';oktime taken:

0.233

seconds

hive (test1)> load data local inpath '

/opt/hadoop/person.data

'into table com_inner_person;

loading data to table test1.com_inner_person

table test1.com_inner_person stats: [numfiles=1, totalsize=142]ok

time taken:

0.602

seconds

hive (test1)> select *from com_inner_person;

ok1 王思琪 12

null

2 張三 13

null

3 王麗 43

null

4 三四 23

刪除表後,資料也一起刪除。 

2.外部表

hive (test1)>create external table com_ext_person (id

int,name string,age int,ctime timestamp) row format delimited fields terminated by '

,' location '

/opt/hadoop/external

';oktime taken:

0.205

seconds

hive (test1)> load data local inpath '

/opt/hadoop/person.data

'into table com_ext_person;

loading data to table test1.com_ext_person

table test1.com_ext_person stats: [numfiles=0, totalsize=0]ok

time taken:

0.512

seconds

hive (test1)> select *from com_ext_person;

ok1 王思琪 12

null

2 張三 13

null

3 王麗 43

null

4 三四 23

在指定的location中檢視hdfs資料

刪除表後,資料仍在。

hive內部表和外部表的區別 內部表和外部表

內部表 create table if not exists table name刪除表時,元資料與資料都會被刪除 外部表 create external table if not exists table name location hdfs path刪除外部表只刪除metastore的元資料,不...

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 ...