Difference between `load data inpath ` and `location` in hive?

前端 未结 2 1388
说谎
说谎 2021-01-04 13:49

At my firm, I see these two commands used frequently, and I\'d like to be aware of the differences, because their functionality seems the same to me:

1

<         


        
2条回答
  •  萌比男神i
    2021-01-04 14:45

    Option 1: Internal table

    create table  
    (name string,
    number double);
    
    load data inpath '/directory-path/file.csv' into ; 
    

    This command will remove content at source directory and create a internal table

    Option 2: External table

     create table 
     (name string,
     number double);
    
    location '/directory-path/file.csv';
    

    Create external table and copy the data into table. Now data won't be moved from source. You can drop external table but still source data is available.

    When you drop an external table, it only drops the meta data of HIVE table. Data still exists at HDFS file location.

    Have a look at this related SE questions regarding use cases for both internal and external tables

    Difference between Hive internal tables and external tables?

提交回复
热议问题