Hive与Oracle之间利用Sqoop进行数据的导入导出

      近期在工作中遇到了Hive与Oracle之间数据导入导出的问题,故整理如下,以供需要者参考。


一、Oracle数据导入到Hive中


/usr/bin/sqoop import \
--connect jdbc:oracle:thin:@72.*.*.185:1521:dbcxj2 \
--username name --password pw \
--table tableName \
-m 1 \
--fields-terminated-by "," \
--hive-database hiveName \
--hive-table hiveTable \
--hive-import \
--hive-overwrite

##解释
72.*.*.185:Oracle数据库所在服务器的IP地址;
dbcxj2:SID号;
name:登录Oracle数据库的用户名;
pw:登录Oracle数据库的密码;
tableName:需要导出数据所在表的表名
hiveName:导入Hive中数据库的名字(数据库需要提前创建好)
hiveTable:导入Hive中表的名字(表需要提前创建好)

二、Hive数据导入到Oracle中


/usr/bin/sqoop export \
--connect jdbc:oracle:thin:@72.*.*.185:1521:dbcxj2 \
--username name \
--password pw \
--table tableName \
--export-dir dir \
--fields-terminated-by ',' \
-m 1

##解释
72.*.*.185:Oracle数据库所在服务器的IP地址;
dbcxj2:SID号;
name:登录Oracle数据库的用户名;
pw:登录Oracle数据库的密码;
dir:hive中数据表的数据在HDFS上的绝对路径

你们在此过程中遇到了什么问题,欢迎留言,让我看看你们都遇到了哪些问题。

猜你喜欢

转载自blog.csdn.net/gdkyxy2013/article/details/80230780