使用sqoop --options-file 导入hive数据

[Author]: kwu


使用sqoop --options-file直接导入hive数据,把操作命令语句写在文件中,便于管理及管理

1、创建hive数据库及表

create database DB_TEST;

CREATE TABLE

    UserRegLoginLog
    (
        ID BIGINT,
        fld_date TIMESTAMP,
        fld_ip string,
        fld_server_ip string,
        fld_UA string,
        UserId BIGINT ,
        UserName string,
        PassWord string,
        ActionType INT ,
        ActionTime TIMESTAMP ,
        ActionIP string,
        FromHost string,
        UrlRefer string,
        RemotePort string
    )
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' ;




2、编写sqoop操作文件,注意做分隔符需要与hive的一致

vi UserRegLoginLog_hive.opt  

[sql]  view plain copy
  1. import   
  2. --connect   
  3. jdbc:jtds:sqlserver://localhost:1433;;DatabaseName=DB_TEST   
  4. --username   
  5. sa   
  6. --password   
  7. 123456  
  8. --table   
  9. UserRegLoginLog  
  10. --where  
  11. 1=1  
  12. --columns  
  13. " ID ,fld_date ,fld_ip ,fld_server_ip ,fld_UA ,UserId  ,UserName ,PassWord ,ActionType  ,ActionTime  ,ActionIP ,FromHost ,UrlRefer,RemotePort "  
  14. --fields-terminated-by   
  15. '\t'  
  16. --hive-import  
  17. --hive-overwrite  
  18. --hive-drop-import-delims  
  19. --hive-table  
  20. DB_TELECAST.UserRegLoginLog  

使用sqoop --options-file 执行操作文本

sqoop --options-file ./UserRegLoginLog_hive.opt


3、指定hive的数据库,格式为: 数据库.表名

DB_TEST.UserRegLoginLog


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值