大数据入门到精通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," ...
随机推荐
- locate中使用variant
利用locate构造多字段查询,采用variant很方便,简介如下, //构造查询多字段,例如'编号;姓名'形式 aLookField := FieldByName ('关键字1').AsStrin ...
- GVIM 设置 vimrc
set expandtab set nobackup set nosmartindent set noautoindent set ruler au BufRead,BufNewFile *.sv s ...
- Galaxy2D Game Engine 4.2
Galaxy2D Game Engine 4.2 开发版 下载地址 D3DRender注意:1.下载后的压缩包请使用WinRar5.0打开.2.开发版包含了现在正在开发中的Galaxy2D游戏引擎 ...
- dpdk环境配置
1.配置流程 [1]修改/boot/grub2/grub.cfg,添加下列标记的配置项. linux16 /vmlinuz--.el7.x86_64 root=/dev/mapper/centos-r ...
- WordPress版微信小程序3.5版发布
最近花时间对WordPress版微信小程序做了一些完善和调整,修复不少程序的问题.一个程序的完善是持续和渐进的,没有最好,只有更完善.虽然会采纳一些用户的建议和意见,但我会从一个产品角度去考虑,哪些功 ...
- liunx vi 学习
vi有两种状态:命令态和编辑态 命令态中常用的命令: 上下左右移动的处理4个箭头外还有h(左),j(下),k(上),l(右) 调到屏幕显示的首行H,尾行L,x行:xG 0将光标移动到行首:$到行尾,M ...
- 编译ijkplayer后直播无声音
打开:ijkplayer-android/config/module-lite.sh 文件: 你要把neyllow打开,默认是关闭的,如下: export COMMON_FF_CFG_FLAGS=&q ...
- IE8图片上传预览
$("#smallImg").attr('style', "filter:progid:DXImageTransform.Microsoft.AlphaImageLoad ...
- Day71Django基础
Django框架基础一 python中的web框架 a:socket b:路由跟视图函数匹配关系 c:模板渲染 django: a: 用了别人的wsgiref b:自己写 ...
- python-web自动化:下拉列表操作
非select/option元素: 1.触发下拉列表出现 2.等待下拉列表中的元素出现,然后进行选择元素即可. select/option元素: 下拉框操作-Select类selenium提供Sele ...