zoukankan      html  css  js  c++  java
  • 数据导入导出

    1.语法

    hive> load data [local] inpath '/opt/module/datas/student.txt' overwrite | into table student [partition (partcol1=val1,…)];

    (1)load data:表示加载数据

    (2)local:表示从本地加载数据到hive表;否则从HDFS加载数据到hive表

    (3)inpath:表示加载数据的路径

    (4)overwrite:表示覆盖表中已有数据,否则表示追加

    (5)into table:表示加载到哪张表

    (6)student:表示具体的表

    (7)partition:表示上传到指定分区

    load data local inpath '/opt/module/datas/student.txt' into table default.student;

    2.导出

    1 Insert导出

    1.将查询的结果导出到本地

    hive (default)> insert overwrite local directory '/opt/module/datas/export/student'

                select * from student;

    2.将查询的结果格式化导出到本地

    hive(default)>insert overwrite local directory '/opt/module/datas/export/student1'

               ROW FORMAT DELIMITED FIELDS TERMINATED BY ' '             select * from student;

    3.将查询的结果导出到HDFS上(没有local)

    hive (default)> insert overwrite directory '/user/atguigu/student2'

                 ROW FORMAT DELIMITED FIELDS TERMINATED BY ' '

                 select * from student;

    2 Hadoop命令导出到本地

    hive (default)> dfs -get /user/hive/warehouse/student/month=201709/000000_0

    /opt/module/datas/export/student3.txt;

    3 Hive Shell 命令导出

    基本语法:(hive -f/-e 执行语句或者脚本 > file)

    [atguigu@hadoop102 hive]$ bin/hive -e 'select * from default.student;' >

     /opt/module/datas/export/student4.txt;

    4 Export导出到HDFS上

    (defahiveult)> export table default.student to

     '/user/hive/warehouse/export/student';

     

  • 相关阅读:
    【kd-tree】bzoj2648 SJY摆棋子
    【kd-tree】bzoj3053 The Closest M Points
    【堆】【kd-tree】bzoj2626 JZPFAR
    【kd-tree】bzoj1941 [Sdoi2010]Hide and Seek
    【kd-tree】bzoj2850 巧克力王国
    【kd-tree】bzoj3489 A simple rmq problem
    【kd-tree】bzoj4066 简单题
    【二维莫队】【二维分块】bzoj2639 矩形计算
    【kd-tree】bzoj1176 [Balkan2007]Mokia
    【kd-tree】bzoj3290 Theresa与数据结构
  • 原文地址:https://www.cnblogs.com/fengchuiguobanxia/p/15351153.html
Copyright © 2011-2022 走看看