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

一:将数据导入hive(六种方式)

1.从本地导入

  load data local inpath 'file_path' into table tbname;

  用于一般的场景。

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

 

2.从hdfs上导入数据

  load data inpath ‘hafd_file_path’ into table tbname;

  使用与大数据的存储

 

3.load方式的覆盖

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

  用于零时表。

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

 

4.子查询方式

  create  table tb2 as select * from tb1;

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

 

5.insert into 

  insert into table tb2 select q1;

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

 

6.location

  然后put就好。

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

  

  在HDFS上看效果

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

 

 

二:将数据从hive里导出(四种方式)

1.insert方式

  1)保存到本地

    insert overwrite local directory 'path' select q1;

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

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

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

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

 

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

 

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

 

  2)保存到HDFS上

   insert overwrite directory 'hdfs_path' select * from dept;

  注意点:hdfs_path必须存在