您的位置:首页 > 其它

将数据导入hive,将数据从hive导出

2018-01-04 14:19 218 查看
一:将数据导入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必须存在
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: