將數據導入hive,將數據從hive導出

一:將數據導入hive(六種方式)

1.從本地導入

  load data local inpath 'file_path' into table tbname;

  用於一般的場景。

  

 

2.從hdfs上導入數據

  load data inpath ‘hafd_file_path’ into table tbname;

  使用與大數據的存儲

 

3.load方式的覆蓋

  load data local inpath 'file_path' overwrite into table tbname;

  用於零時表。

   

 

4.子查詢方式

  create  table tb2 as select * from tb1;

  

 

5.insert into 

  insert into table tb2 select q1;

  

 

6.location

  然後put就好。

  

  

  在HDFS上看效果

  

 

 

二:將數據從hive裏導出(四種方式)

1.insert方式

  1)保存到本地

    insert overwrite local directory 'path' select q1;

    

    但是效果不好,沒有分隔符

    

    insert overwrite local directory 'path'  row format delimited  fields terminated by '\t' select q1;

 

    

 

    

 

  2)保存到HDFS上

   insert overwrite directory 'hdfs_path' select * from dept;

  注意點:hdfs_path必須存在