sqoop将Mysql数据传入Hive中

本文介绍如何使用Hive SQL创建指定结构的数据表,并通过Sqoop工具将MySQL中的数据迁移到Hive表中,实现数据的高效转移。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、HIve创建表

CREATE TABLE`piwik_log_link_visit_action` (

  `idlink_va` int(11) unsigned NOT NULLAUTO_INCREMENT,

  `idsite` int(10) unsigned NOT NULL,

  `idvisitor` binary(8) NOT NULL,

  `idvisit` int(10) unsigned NOT NULL,

  `idaction_url_ref` int(10) unsigned DEFAULT'0',

  `idaction_name_ref` int(10) unsigned NOTNULL,

  `custom_float` float DEFAULT NULL,

  `server_time` datetime NOT NULL,

  `idaction_name` int(10) unsigned DEFAULTNULL,

  `idaction_url` int(10) unsigned DEFAULT NULL,

  `time_spent_ref_action` int(10) unsigned NOTNULL

) row format delimited fields terminated by '\t';


2、Sqoop将mysql中指定表转移到Hive的piwik_log_link_visit_action中

     sqoop  import --connect jdbc:mysql://192.168.1.10:3306/itcast --username root--password 123 --table piwik_log_link_visit_action --hive-import --hive-overwrite --hive-table  piwik_log_link_visit_action --fields-terminated-by '\t'

     

备注:将mysql中指定表结构复制到hive中,比如将mysql的piwik_log_link_visit_action表结构复制到hive的piwik_log_link_visit_action表

sqoop import  --connect jdbc:mysql://192.168.1.10:3306/itcast  --table piwik_log_link_visit_action --username root  --password 123  --hive-import --hive-overwrite --hive-table piwik_log_link_visit_action --fields-terminated-by '\t'







评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值