1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > [hive] hive 内部表和外部表

[hive] hive 内部表和外部表

时间:2020-10-05 07:06:44

相关推荐

[hive] hive 内部表和外部表

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 secondshive (test1)> load data local inpath '/opt/hadoop/person.data' into table com_inner_person;Loading data to table _inner_personTable _inner_person stats: [numFiles=1, totalSize=142]OKTime taken: 0.602 secondshive (test1)> select * from com_inner_person;OK1 王思琪 12NULL2 张三 13NULL3 王丽 43NULL4 三四 23NULL5 Python 12NULLTime taken: 0.075 seconds, Fetched: 5 row(s)

删除表后,数据也一起删除。

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 secondshive (test1)> load data local inpath '/opt/hadoop/person.data' into table com_ext_person;Loading data to table _ext_personTable _ext_person stats: [numFiles=0, totalSize=0]OKTime taken: 0.512 secondshive (test1)> select * from com_ext_person;OK1 王思琪 12NULL2 张三 13NULL3 王丽 43NULL4 三四 23NULL5 Python 12NULL6 spark 32NULLTime taken: 0.086 seconds, Fetched: 6 row(s)

在指定的location中查看hdfs数据

删除表后,数据仍在。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。