zoukankan      html  css  js  c++  java
  • sqoop操作之HIVE导出到ORACLE

    示例数据准备

    hive中创建dept表

    create table dept(
    deptno int,
    dname string,
    loc string
    )
    row format delimited fields terminated by '	' lines terminated by '
    ' 
    stored as textfile;

    导入数据:

    sqoop import --connect jdbc:oracle:thin:@192.168.1.107:1521:ORCL 
    --username SCOTT --password tiger 
    --table DEPT  
    --hive-overwrite --hive-import  --hive-table dept 
    --fields-terminated-by '	' --lines-terminated-by '
    ' 
    -m 3;

    HIVE导出到ORACLE

    需要分两步:
    第一步:先写入到hdfs

    insert overwrite directory '/user/hadoop/DEPT_HIVE_EXPORT' select * from dept;

    第二步:由hdfs导出到oracle

    导出到数据库时,要确保表已经在数据库中存在,否则报错。

    create table DEPT_DEMO as select * from DEPT where 1=2;
    sqoop export
    --connect jdbc:oracle:thin:@192.168.1.107:1521:ORCL --username SCOTT --password tiger --table DEPT_DEMO --export-dir /user/hadoop/DEPT_HIVE_EXPORT --fields-terminated-by '01' -m 2;

    注:从hive导出到hdfs的分隔符不是,而是01;如果不指定分隔符,则报错:Caused by: java.lang.NumberFormatException

     

  • 相关阅读:
    Excel如何关闭进程
    Excel_To_DataTable
    将本地项目上传到Github
    对于session,request,cookie的理解
    static的使用
    Java事件监听的四种实现方式
    静态网页和动态网页
    ps -ef|grep详解
    linux ls -l 详解
    PKU2418_树种统计(map应用||Trie树)
  • 原文地址:https://www.cnblogs.com/luogankun/p/3895351.html
Copyright © 2011-2022 走看看