[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=, totalSize=]
OK
Time taken: 0.602 seconds
hive (test1)> select * from com_inner_person;
OK
王思琪 NULL
张三 NULL
王丽 NULL
三四 NULL
Python NULL
Time taken: 0.075 seconds, Fetched: row(s)

[hive] hive 内部表和外部表

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

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=, totalSize=]
OK
Time taken: 0.512 seconds
hive (test1)> select * from com_ext_person;
OK
王思琪 NULL
张三 NULL
王丽 NULL
三四 NULL
Python NULL
spark NULL
Time taken: 0.086 seconds, Fetched: row(s)

[hive] hive 内部表和外部表

在指定的location中查看hdfs数据

[hive] hive 内部表和外部表

删除表后,数据仍在。

[hive] hive 内部表和外部表

上一篇:小白的Python之路 day2 列表、元组操作


下一篇:Python基础(六)