一。正常按照数据库和表导入

\\前面介绍了通过底层文件得形式导入到hive的表中,或者直接导入到hdfs中,
\\现在介绍通过hive的database和table命令来从上层操作。
sqoop import --connect "jdbc:mysql://host03.xyy:3306/sakila" --username root --password root --table payment --where "payment_id<=8000" --hive-import --hive-database sakila --hive-table payment --delete-target-dir --num-mappers 2
\\追加导入数据
sqoop import --connect "jdbc:mysql://host03.xyy:3306/sakila" --username root --password root --table payment --where "payment_id >8000" --hive-import --hive-database sakila --hive-table payment --num-mappers 2
二、默认导入都是追加到表的方式,如果是期望覆盖的方式
sqoop import --connect "jdbc:mysql://host03.xyy:3306/sakila" --username root --password root --table payment --where "payment_id >8000" --hive-import --hive-database sakila --hive-table payment hive-overwrite -- --num-mappers 2

三、创建表,并自动在hive里面创建新表,并指定列类型转换对应关系
sqoop import --connect "jdbc:mysql://host03.xyy:3306/sakila" --username root --password root --table payment --hive-import --hive-database sakila --hive-table payment2 --create-hive-table --map-column-hive payment_date=date,last_update=date --num-mappers 2

hive> desc payment;
OK
payment_id int
customer_id int
staff_id tinyint
rental_id int
amount double
payment_date string
last_update string
Time taken: 0.07 seconds, Fetched: 7 row(s)
hive> desc payment2;
OK
payment_id int
customer_id int
staff_id tinyint
rental_id int
amount double
payment_date date
last_update date
Time taken: 0.063 seconds, Fetched: 7 row(s)

四、导入全部数据库,
sqoop import-all-tables --connect "jdbc:mysql://host03.xyy:3306/sakila" --username root --password root --hive-import --hive-database sakila --num-mappers 2

大数据入门到精通19--mysql 数据导入到hive数据中的更多相关文章

  1. 11.把文本文件的数据导入到Hive表中

    先在hive里面创建一个表 create table mydb2.t3(id int,name string,age int) row format delimited fields terminat ...

  2. 大数据入门到精通18--sqoop 导入关系库到hdfs中和hive表中

    一,选择数据库,这里使用标准mysql sakila数据库 mysql -u root -D sakila -p 二.首先尝试把表中的数据导入到hdfs文件中,这样后续就可以使用spark来dataf ...

  3. 人工智能AI从入门到精通所有视频教程(140G)以及数据资料免费拿

    包含了人工智能AI从入门到精通所有视频教程(140G). 资料获取方式,关注公总号RaoRao1994,查看往期精彩-所有文章,即可获取资源下载链接 更多资源获取,请关注公总号RaoRao1994

  4. 用sqoop将mysql的数据导入到hive表中

    1:先将mysql一张表的数据用sqoop导入到hdfs中 准备一张表 需求 将 bbs_product 表中的前100条数据导 导出来  只要id  brand_id和 name 这3个字段 数据存 ...

  5. MyBatis从入门到精通(第9章):Spring集成MyBatis(中)

    MyBatis从入门到精通(第9章):Spring集成MyBatis(中) 框架(Framework)是整个或部分系统的可重用设计,表现为一组抽象构件及构件实例间交互的方法.应该将应用自身的设计和具体 ...

  6. 大数据入门到精通13--为后续和MySQL数据库准备

    We will be using the sakila database extensively inside the rest of the course and it would be great ...

  7. 大数据入门到精通12--spark dataframe 注册成hive 的临时表

    一.获得最初的数据并形成dataframe val ny= sc.textFile("data/new_york/")val header=ny.firstval filterNY ...

  8. 大数据入门到精通2--spark rdd 获得数据的三种方法

    通过hdfs或者spark用户登录操作系统,执行spark-shell spark-shell 也可以带参数,这样就覆盖了默认得参数 spark-shell --master yarn --num-e ...

  9. 大数据入门到精通16--hive 的条件语句和聚合函数

    一.条件表达 case when ... then when .... then ... when ... then ...end select film_id,rpad(title,20," ...

随机推荐

  1. 【C++】智能指针简单剖析

    转自 http://www.cnblogs.com/lanxuezaipiao/p/4132096.html 导读 最近在补看<C++ Primer Plus>第六版,这的确是本好书,其中 ...

  2. CSS3 Vendor-prefixing

    Browser vendors needed a way to add support for new features that were not yet standardized, but wit ...

  3. VMware与Centos系统安装

    Linux介绍 1. Linux Linux和windows一样都是操作系统,Linux是开源的.免费的.自由传播的类Unix操作系统软件. 是一个基于POSIX和UNIX的多用户.多任务.支持多线程 ...

  4. ocr_vote disk损坏恢复

    1. 检查votedisk和 ocr备份[root@rh6rac1 bin]./ocrconfig -showbackuprh6rac1     2019/03/19 16:57:40     /or ...

  5. C#求一组数的众数

    private int GetModeNum(List<int> listValue) { List<int> listName = new List<int>() ...

  6. VB 调用 webservice 出现:WSDLReader:Loading of the WSDL file failed HRESULT=0×80040154: 没有注册类别 解决方案

    有些 VB 程序在调用  webservice  的时候出现“WSDLReader:Loading of the WSDL file failed HRESULT=0×80040154: 没有注册类别 ...

  7. asp微信支付代码v4.1无需证书版,带回调入库的asp支付源码

    昨天帮一个客户写的,他的程序是老的asp,想实现微信在手机上下单付款,让帮忙给写一份asp微信支付的接口代码,昨天晚上闲着没事,搞了一个晚上才搞好,其实asp支付并不需要安装证书,其实asp支付也很好 ...

  8. C#,ASP.NET简单的MD5加密,解密

    简单的MD5加密 首先要有一个加解密的规则  就是key 代码如下 // 创建Key public string GenerateKey() { DESCryptoServiceProvider de ...

  9. docker学习记录

    Container 容器是一种基础工具, 泛指任何容纳其他物品的工具, 可以部分或者完全封闭,被用于容纳,储存, 运输物品, 物体可以放置在容器中, 而容器可以保护内容物 1 Docker Objec ...

  10. no module named selenium

    I am having the same problem. I have downgraded selenium for now. pip uninstall selenium pip install ...