hive 导入数据
1、load data
load data local inpath "/home/hadoop/userinfo.txt" into table userinfo; load data inpath "/mysql/syslog2/part-m-00000" into table syslog;
2、insert
hive> insert into userinfo2 values(25,'test_user');
insert into table weather_list select year,data from weather_data; insert overwritetable weather_list select year,data from weather_data; insert into table weather_list partition(createtime='2012-01-01',area='gz') select year,data from weather_data; insert overwritetable table weather_list partition(createtime='2012-01-01',area='gz') select year,data from weather_data; #动态分区
insert into table weather_list partition(createtime='2012-01-02',area) select year,data,'gz' from weather_data;
hive> insert into table weather_list partition(createtime,area) select year,data,'2013-01-01','gz' from weather_data;
FAILED: SemanticException [Error 10096]: Dynamic partition strict mode requires at least one static partition column. To turn this off set hive.exec.dynamic.partition.mode=nonstrict
hive> set hive.exec.dynamic.partition.mode=nonstrict;
hive> insert into table weather_list partition(createtime,area) select year,data,'2013-01-01','gz' from weather_data;
3、多表插入,在单表插入的时候,from子句可以放在前面,这个特性在多表插入的时候被应用
#建立三张表,分别按年份存最大,最小,计数
hive> create table weather_max(year int,mdata int) row format delimited fields terminated by ',';
OK
Time taken: 0.519 seconds
hive> create table weather_min(year int,mdata int) row format delimited fields terminated by ',';
OK
Time taken: 0.471 seconds
hive> create table weather_count(year int,cdata int) row format delimited fields terminated by ',';
OK
Time taken: 0.258 seconds hive> from weather_data
> insert into weather_max select year,max(data) group by year
> insert into weather_min select year,min(data) group by year
> insert into weather_count select year,count(1) group by year;
4、使用CTAS创建表并导入数据,create table ... as select ...
hive> create table userinfo2 as select userid,username from userinfo;
hive 导入数据的更多相关文章
- 使用Sqoop从mysql向hdfs或者hive导入数据时出现的一些错误
1.原表没有设置主键,出现错误提示: ERROR tool.ImportTool: Error during import: No primary key could be found for tab ...
- 【转】hive导入数据出现NULL
在把hdfs上数据迁移到hive中的表时,若出现数据位NULL,是因为没有指定列分隔符. 由于hive默认的分隔符是/u0001(Ctrl+A),为了平滑迁移,需要在创建表格时指定数据的分割符号,语法 ...
- sqoop从hive导入数据到mysql时出现主键冲突
今天在将一个hive数仓表导出到mysql数据库时出现进度条一直维持在95%一段时间后提示失败的情况,搞了好久才解决.使用的环境是HUE中的Oozie的workflow任何调用sqoop命令,该死的o ...
- Hive导入数据的四种方法
Hive的几种常见的数据导入方式这里介绍四种:(1).从本地文件系统中导入数据到Hive表:(2).从HDFS上导入数据到Hive表:(3).从别的表中查询出相应的数据并导入到Hive表中:(4).在 ...
- hive导入数据
替换分隔符为\ sed -i 's/\t/\x1/g;s/;/\x1/g' test1.txt gz压缩 gzip -r test1.txt 查看文件 hdfs dfs -ls /hive/wareh ...
- Hive导入数据到HBase,再与Phoenix映射同步
1. 创建HBase 表 create 'hbase_test','user' 2. 插入数据 put 'hbase_test','111','user:name','jack' put 'hbase ...
- Sqoop增量从MySQL中向hive导入数据
sqoop job --create incretest -- import --connect jdbc:mysql://10.8.2.19:3306/db --table table1 --use ...
- Hive导入导出数据的方法
Hive导入数据的方式 官网文档: LOAD DATA [LOCAL] INPATH 'filepath' [OVERWRITE] INTO TABLE tablename [PARTITION (p ...
- sqoop1.4.7 导入数据到hive2.3.4 jackson版本问题
今天用sqoop往hive导入数据的时候,执行报错,错误信息为: java.lang.NoSuchMethodError:com.fasterxml.jackson.databind.ObjectMa ...
随机推荐
- Mac下 Windows 7 虚拟机成功搭建SVN服务器后如何与Xcode建立联系,并上传原始工程的详细步骤
内容中包含 base64string 图片造成字符过多,拒绝显示
- arcpy示范教学(一):基本操作
arcpy基本操作 打开目录,遍历目录,打开要素类,遍历要素,打开文件,写入属性值 import arcpy import codecs # 设置工作目录 arcpy.env.workspace = ...
- Struts 2(一):初识Struts
[很久以前的笔记,后续继续完善] 在了解Struts 2框架之前,首先了解一下Model 1和Model 2架构,以及它们的优缺点. 1.1 Model 1架构模式 Model 1的核心是JSP文件, ...
- Siki_Unity_2-7_Stealth秘密行动
Unity 2-7 Stealth秘密行动 Abstract:向量运算:Animation动画:Navigation寻路系统:Mecanim动画系统 任务1&2&3:游戏介绍 & ...
- Centos6升级至openssh-7.5p1
最近公司有几台服务器需要搬至甲方(政府单位),所以在安装服务时用的是16年的openssh7.3pl, 今天通知我们有漏洞,需要再一次升级,看到官方文档上版本已升级至7.5,所以干脆直接搞7.5 具体 ...
- 从零开始的Python学习Episode 7——文件基本操作
文件基本操作 一.打开文件 f = open('11','r')#open('file path','mode') 创建一个文件对象 文件有多种打开模式: 1. 'r':新建一个文件对象以只读方式打开 ...
- POJ 3579 Median 二分加判断
Median Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 12453 Accepted: 4357 Descripti ...
- scikit-learn 0.18中的cross_validation模块被移除
环境:scikit-learn 0.18 , python3 from sklearn.cross_validation import train_test_split from sklearn.gr ...
- centos 系统初始化
centos 系统初始化 #!/bin/bash # author cfwl create date of 2012-10-21 # blog http://cfwlxf.blog.51cto.com ...
- IT工具使用
linux 其他知识目录 常用快捷键总结 博客view code 删除,先删除,再清除格式