当前位置:   article > 正文

hive外部表改为内部表_Hive外部表与内部表命令

hive 变内部表

Assuming I have these two tables:

External:

create external table emp_feedback (

emp_id int,

emp_name string

)

LOCATION '/user/hive/warehouse/mydb.db/contacts';

Internal:

create table emp_feedback (

emp_id int,

emp_name string

)

LOAD DATA INPATH 'file_location_of_csv' INTO TABLE emp_feedback;

When I say: LOCATION '/user/hive/warehouse/mydb.db/contacts'; for the external table does that mean that the data for that table is found in the directory '/user/hive/warehouse/mydb.db/contacts';? So that directory has to exist in HDFS before hand?

Can I use LOAD DATA INPATH... for an external table or is that only used for internal tables. And vice versa can I use Location... for an internal table?

解决方案(a) Yes. You are right, it means that the data is found in that location/directory

(b) No. The directory doesn't have to exist to create a Schema, Hive will create the directory if it doesn't exist. But there is no point in doing as your table will be empty therefore your query will be empty. But in the future, you can move data to that location and use that table.

(a) LOAD DATA INPATH can be used for both external and internal tables. When you do, it moves the data, to the location specified by the schema (for external tables) or to /.../warehouse/... (for internal tables)

(b) location can be specified for both internal and external tables. But when you drop the internal table, it will also remove the data from that location, whereas only meta data information is removed for external tables.

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/喵喵爱编程/article/detail/951479
推荐阅读
相关标签
  

闽ICP备14008679号