sqoop oracle数据到hive

第一步,查看oracle表DEPT对应的信息:


第二步,在hive中创建对应的表

create table oracletohive(

DEPTNO string,

DNAME string,

LOC string);


第三步,使用sqoop导出oracle数据到hive中

sqoop import --connect jdbc:oracle:thin:@10.150.XX.XX:1521:数据库名 \

扫描二维码关注公众号,回复: 2653671 查看本文章

--username USERNAME \

--password password --verbose  --table TABLE  --columns DEPTNO,DNAME,LOC \

--hive-import \

--hive-database tmp --hive-table oracletohive  \

--fields-terminated-by "\t" --lines-terminated-by "\n" --split-by "DEPTNO" \

--direct -m 1 --target-dir /tmp/hive/test1


Note:

    用户名和表名大写;

    --split-by是第一个字段名;

    具体选项参数请参照官网:http://archive.cloudera.com/cdh/3/sqoop/SqoopUserGuide.html#_incremental_imports


第四步,查询

select * from oracletohive;


ok!

猜你喜欢

转载自blog.csdn.net/qq_33004309/article/details/79868852