SQOOP抽取各类型数据库脚本示例

------------MySQL------------
导入到HDFS
sqoop import --connect jdbc:mysql://localhost:3306/wht --username root --password cloudera --table people --fields-terminated-by ',' --target-dir /user/hive/warehouse/cust --delete-target-dir --null-string '' --null-non-string ''   -m 1

导入到Hive
sqoop import --connect jdbc:mysql://localhost:3306/wht --username root --password cloudera --table people --fields-terminated-by ','  --hive-import --hive-table db01.peopleseq --hive-overwrite  -m 1

---------------ORACLE------------

导入到HDFS
sqoop import --connect jdbc:oracle:thin:@192.168.20.104:1521:xe --username dep --password Dep2018 --table WHT_C --fields-terminated-by '\001' --target-dir /user/hive/warehouse/oracledb/wht_c  --delete-target-dir -m 1


导入到Hive
sqoop import --hive-import --connect jdbc:oracle:thin:@192.168.20.104:1521:xe --username dep --password Dep2018 --table WHT_C --hive-database  oracledb --hive-table wht_c --fields-terminated-by '\001' --hive-overwrite  -m 1

------------DB2------------
导入到HDFS
sqoop import --connect jdbc:db2://192.168.20.104:60000/dep --username db2inst1 --password Server2008! --table wht_test  --fields-terminated-by '\001' --target-dir --delete-target-dir   /user/hive/warehouse/db2db/wht_test  -m 1

sqoop import --hive-import --connect jdbc:db2://192.168.20.104:60000/dep --username db2inst1 --password Server2008! --table wht_test --hive-database  db2db --hive-table wht_test --fields-terminated-by '\001' --hive-overwrite  -m 1

------------SQL SERVER------------
导入到HDFS
sqoop import --connect 'jdbc:sqlserver://192.168.20.105:1433;databasename=dep' --username sa --password Server2008!  --table wht_b --fields-terminated-by '\001' --target-dir /user/hive/warehouse/sqlserverdb/wht_b1  --delete-target-dir  -m 1

导入到Hive
sqoop import --hive-import --connect 'jdbc:sqlserver://192.168.20.105:1433;databasename=dep' --username sa --password Server2008!  --table wht_b --hive-database  sqlserverdb --hive-table wht_b  --fields-terminated-by '\001' --hive-overwrite  -m 1

-------------PG------------
导入到HDFS
sqoop import --connect  jdbc:postgresql://192.168.20.104:5432/wht --username postgres --password Server2008!  --table wht_a --fields-terminated-by '\t' --target-dir /user/hive/warehouse/pgdb/wht_a  --delete-target-dir -m 1

导入到Hive
sqoop import --hive-import --connect  jdbc:postgresql://192.168.20.104:5432/wht --username postgres --password Server2008!  --table wht_a   --hive-database  pgdb --hive-table wht_a  --fields-terminated-by '\t' --hive-overwrite  -m 1



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

汀桦坞

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值