sqoop import SqlServer to hive

使用sqoop导出SqlServer数据库具体表数据到Hive数据库:

sqoop import语句:

按表中字段筛选$SQOOP_HOME/bin/sqoop import \
--connect 'jdbc:sqlserver://168.16.8.168:5419;database=database_name' \
--username 'user' \
--password '12345678' \
--table dt_tablename \
--columns 'id,createtime,name,mobile' \
--null-string '\\N' \ ##没有这个,导入的数据值都为NULL
--hive-import \
--hive-database hiveDatabase \
--hive-table tablename_h \
--fields-terminated-by '\001' \
--hive-drop-import-delims \

--incremental append \
--check-column id \
--last-value 1 \

--m 2
自主写sql

/bin/sqoop import \
--connect 'jdbc:sqlserver://168.16.8.168:5419;database=database_name' \
--username 'user' \
--password '12345678' \
--query 'select id,name,mobile,source from wx_member' \
--null-string '\\N' \
--hive-import \
--hive-database rt1 \
--hive-table wx_member_hs \
--fields-terminated-by '\001' \
--hive-drop-import-delims \
--incremental append \
--check-column id \
--last-value 1 \
--m 2

注意,用--query When importing a free-form query, you must specify a destination directory with --target-dir.

导入自由格式查询时,必须使用--target dir指定目标目录。

  

sqoop参数说明:

--columns <col,col,col…>Columns to export to table
  
-e,--query <statement>

Sqoop can also import the result set of an arbitrary SQL query.
 Instead of using the --table, --columns and --where arguments, you can specify a SQL statement with the --query argument.

Sqoop还可以导入任意SQL查询的结果集。可以使用--query参数指定SQL语句,而不是使用--table、--columns和--where参数。

注意不和 --table--columns and --where 一起使用。

  
--create-hive-table

If set, then the job will fail if the target hive table exits. By default this property is false.

如果设置,则如果目标配置单元表退出,则作业将失败。默认情况下,此属性为false。

--hive-overwrite

Overwrite existing data in the Hive table.

覆盖配置单元表中的现有数据

--hive-drop-import-delims

Drops \n, \r, and \01 from string fields when importing to Hive.

导入配置单元时,从字符串字段中删除\n、\r和\01。

--incremental

Specifies how Sqoop determines which rows are new. Legal values for mode include append and lastmodified.

指定Sqoop如何确定哪些行是新的。合法值包括mode,append和lastmodified。

--null-string '\\N'

The string to be written for a null value for string columns

要为字符串列的空值写入的字符串

详细信息见官网7.2.12. Importing Data Into Hive

  
  
  
  

更新中。。。

官网地址:http://sqoop.apache.org/docs/1.4.6/SqoopUserGuide.html#_importing_data_into_hive

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值