[hive] hive 内部表和外部表

1.内部表

hive (test1)> create table com_inner_person(id int,name string,age int,ctime timestamp) row format delimited fields terminated by ',';
OK
Time 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;
OK
1       王思琪  12      NULL
2       张三    13      NULL
3       王丽    43      NULL
4       三四    23      NULL
5       Python  12      NULL
Time taken: 0.075 seconds, Fetched: 5 row(s)

[hive] hive 内部表和外部表

删除该表后,数据也将被删除。

[En]

After the table is deleted, the data is also deleted.

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';
OK
Time 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;
OK
1       王思琪  12      NULL
2       张三    13      NULL
3       王丽    43      NULL
4       三四    23      NULL
5       Python  12      NULL
6       spark   32      NULL
Time taken: 0.086 seconds, Fetched: 6 row(s)

[hive] hive 内部表和外部表

在指定位置查看HDFS数据

[En]

View hdfs data in the specified location

[hive] hive 内部表和外部表

表被删除后,数据仍在那里。

[En]

After the table is deleted, the data is still there.

Original: https://www.cnblogs.com/lonelywolfmoutain/p/6929830.html
Author: snow__wolf
Title: [hive] hive 内部表和外部表

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/6881/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

免费咨询
免费咨询
扫码关注
扫码关注
联系站长

站长Johngo!

大数据和算法重度研究者!

持续产出大数据、算法、LeetCode干货,以及业界好资源!

2022012703491714

微信来撩,免费咨询:xiaozhu_tec

分享本页
返回顶部