大数据入门到精通19--mysql 数据导入到hive数据中
一。正常按照数据库和表导入
\\前面介绍了通过底层文件得形式导入到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数据中的更多相关文章
- 11.把文本文件的数据导入到Hive表中
先在hive里面创建一个表 create table mydb2.t3(id int,name string,age int) row format delimited fields terminat ...
- 大数据入门到精通18--sqoop 导入关系库到hdfs中和hive表中
一,选择数据库,这里使用标准mysql sakila数据库 mysql -u root -D sakila -p 二.首先尝试把表中的数据导入到hdfs文件中,这样后续就可以使用spark来dataf ...
- 人工智能AI从入门到精通所有视频教程(140G)以及数据资料免费拿
包含了人工智能AI从入门到精通所有视频教程(140G). 资料获取方式,关注公总号RaoRao1994,查看往期精彩-所有文章,即可获取资源下载链接 更多资源获取,请关注公总号RaoRao1994
- 用sqoop将mysql的数据导入到hive表中
1:先将mysql一张表的数据用sqoop导入到hdfs中 准备一张表 需求 将 bbs_product 表中的前100条数据导 导出来 只要id brand_id和 name 这3个字段 数据存 ...
- MyBatis从入门到精通(第9章):Spring集成MyBatis(中)
MyBatis从入门到精通(第9章):Spring集成MyBatis(中) 框架(Framework)是整个或部分系统的可重用设计,表现为一组抽象构件及构件实例间交互的方法.应该将应用自身的设计和具体 ...
- 大数据入门到精通13--为后续和MySQL数据库准备
We will be using the sakila database extensively inside the rest of the course and it would be great ...
- 大数据入门到精通12--spark dataframe 注册成hive 的临时表
一.获得最初的数据并形成dataframe val ny= sc.textFile("data/new_york/")val header=ny.firstval filterNY ...
- 大数据入门到精通2--spark rdd 获得数据的三种方法
通过hdfs或者spark用户登录操作系统,执行spark-shell spark-shell 也可以带参数,这样就覆盖了默认得参数 spark-shell --master yarn --num-e ...
- 大数据入门到精通16--hive 的条件语句和聚合函数
一.条件表达 case when ... then when .... then ... when ... then ...end select film_id,rpad(title,20," ...
随机推荐
- iOS业务模块化利用CocoaPod入门实践
iOS业务模块化即是通过不同的工程管理不同的业务,通常应用在中大型项目中,这样做的好处主要有:1.多人开发时,防止工程文件冲突 2.能够为下个不同的项目抽取代码,话不多说,直接看步骤:括号内容为本例 ...
- RN 的页面布局
从 https://blog.csdn.net/liangzelei/article/details/53965417转载 React Native布局详细指南 https://www.jiansh ...
- @RequestParam、@ReqeustBody、@ReponseBody认识
简介: @RequestParam和@RequestBody均是处理request body部分的注解,都用于获取请求部分的参数. @ResponseBody是用于响应部分的注解 1. @Reques ...
- Galaxy2D Game Engine 4.2 开发版发布
Update: ◆删除Graph_GetRenderTarget()函数,添加Graph_CopyBackBuffer()/Graph_CopyRanderTarget()函数 ◆Graph_EndS ...
- java 垃圾回收总结(1)(转)
转自: http://www.cnblogs.com/aigongsi/archive/2012/04/06/2434771.html 另外可参考: http://ifeve.com/gc-orien ...
- Spring Security开发Restful服务
2-1开发环境安装 1.jdk8安装 2.安装STS Spring Tool Suite实际上就是一个eclipse,只不过在此基础上又安装了一些插件 3.安装mysql 2-2代码结构介绍 打 ...
- 基于vue和svg的树形UI
vue-svg-tree 基于vue和svg的动态树形UI 截图 应用 npm install vue-svg-tree 示例 <template> <div> <v ...
- Java 基于WebMagic 开发的网络爬虫
第一次接触爬虫,之所以选择WebMagic,是因为文档齐全.用法简单.而且框架一直在维护. WebMagic是一个简单灵活的Java爬虫框架.基于WebMagic,我们可以快速开发出一个高效.易维护的 ...
- H3路由器映射端口到外网
登录华三路由器 依次点击菜单 “防火墙”-->“NAT”-->“内部服务器” 将看到一个内部服务器转换的列表页面 点击列表页面的的新建然后完善页面提交即可 如下操作:
- 215.Spring Boot+Spring Security:初体验
[视频&交流平台] SpringBoot视频:http://t.cn/R3QepWG Spring Cloud视频:http://t.cn/R3QeRZc SpringBoot Shiro视频 ...