• Hive表数据导出


    方式一: hadoop命令导出

    hadoop fs -get hdfs://hadoop000:8020/data/page_views2   pv2 

    方式二:通过insert...directory导出 【spark暂不支持】

    导出到本地:

    INSERT OVERWRITE LOCAL directory '/home/spark/hivetmp/'
    ROW FORMAT DELIMITED FIELDS TERMINATED BY '	' LINES TERMINATED BY '
    '
    select * from page_views;

    导出到HDFS:

    INSERT OVERWRITE directory '/hivetmp/'
    ROW FORMAT DELIMITED FIELDS TERMINATED BY '	' LINES TERMINATED BY '
    '
    select * from page_views;

    报错:cannot recognize input near 'ROW' 'FORMAT' 'DELIMITED' in select clause

    INSERT OVERWRITE directory '/hivetmp/'
    select * from page_views;

    注意: 导出到本地可以通过ROW FORMAT来设置分隔符,导出到HDFS是不能设置分隔符的

    方式三: shell命令 + 管道(hive -f/-e | sed/grep/awk > file)

    hive -e "select * from page_views limit 5"
    hive -S -e "select * from page_views limit 5" | grep B58W48U4WKZCJ5D1T3Z9ZY88RU7QA7B1
    hive -S -e "select * from page_views limit 5" | grep B58W48U4WKZCJ5D1T3Z9ZY88RU7QA7B1 > file

    方式四: sqoop

    详见sqoop章节:http://www.cnblogs.com/luogankun/category/601761.html

  • 相关阅读:
    HDU 5313 bitset优化背包
    bzoj 2595 斯坦纳树
    COJ 1287 求匹配串在模式串中出现的次数
    HDU 5381 The sum of gcd
    POJ 1739
    HDU 3377 插头dp
    HDU 1693 二进制表示的简单插头dp
    HDU 5353
    URAL 1519 基础插头DP
    UVA 10294 等价类计数
  • 原文地址:https://www.cnblogs.com/luogankun/p/4108482.html
Copyright © 2020-2023  润新知