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 导入数据的更多相关文章

  1. 使用Sqoop从mysql向hdfs或者hive导入数据时出现的一些错误

    1.原表没有设置主键,出现错误提示: ERROR tool.ImportTool: Error during import: No primary key could be found for tab ...

  2. 【转】hive导入数据出现NULL

    在把hdfs上数据迁移到hive中的表时,若出现数据位NULL,是因为没有指定列分隔符. 由于hive默认的分隔符是/u0001(Ctrl+A),为了平滑迁移,需要在创建表格时指定数据的分割符号,语法 ...

  3. sqoop从hive导入数据到mysql时出现主键冲突

    今天在将一个hive数仓表导出到mysql数据库时出现进度条一直维持在95%一段时间后提示失败的情况,搞了好久才解决.使用的环境是HUE中的Oozie的workflow任何调用sqoop命令,该死的o ...

  4. Hive导入数据的四种方法

    Hive的几种常见的数据导入方式这里介绍四种:(1).从本地文件系统中导入数据到Hive表:(2).从HDFS上导入数据到Hive表:(3).从别的表中查询出相应的数据并导入到Hive表中:(4).在 ...

  5. hive导入数据

    替换分隔符为\ sed -i 's/\t/\x1/g;s/;/\x1/g' test1.txt gz压缩 gzip -r test1.txt 查看文件 hdfs dfs -ls /hive/wareh ...

  6. Hive导入数据到HBase,再与Phoenix映射同步

    1. 创建HBase 表 create 'hbase_test','user' 2. 插入数据 put 'hbase_test','111','user:name','jack' put 'hbase ...

  7. Sqoop增量从MySQL中向hive导入数据

    sqoop job --create incretest -- import --connect jdbc:mysql://10.8.2.19:3306/db --table table1 --use ...

  8. Hive导入导出数据的方法

    Hive导入数据的方式 官网文档: LOAD DATA [LOCAL] INPATH 'filepath' [OVERWRITE] INTO TABLE tablename [PARTITION (p ...

  9. sqoop1.4.7 导入数据到hive2.3.4 jackson版本问题

    今天用sqoop往hive导入数据的时候,执行报错,错误信息为: java.lang.NoSuchMethodError:com.fasterxml.jackson.databind.ObjectMa ...

随机推荐

  1. Spring Boot:Caused by: org.apache.ibatis.binding.BindingException: Parameter 'deptId' not found.

    1. 错误信息描述 在使用Spring Boot + Mybaits从前台向后台提交数据时,控制台报出该错误信息 2. 报错原因 在dao接口中,该方法拥有两个参数,Mybaits无法区分这两个参数 ...

  2. 电信NB-IOT的温湿度采集器开发记录

    1. 首先打开浏览器,登录电信商用服务器,上传profile文件 2. 上传编解码插件在,注意的是,上传编解码插件是电信测试用服务器平台(不同的网址),反正不明白电信搞啥幺蛾子,得两个地方去上传 3. ...

  3. 如何在存储过程的IN操作中传递字符串变量

    原始SQL如下: SELECT MONTH(OrderTime) AS datetype, SUM(DeliveryCount) AS decount, Region FROM (SELECT dbo ...

  4. 向日期添加指定的时间间隔(mysql)

    DATE_ADD( 原始日期, INTERVAL 要加的年数 YEAR) DATE_ADD( 原始日期, INTERVAL 要加的月份 MONTH) DATE_ADD( 原始日期, INTERVAL ...

  5. 手摸手,和你一起学习 UiPath Studio

    学习 RPA 的路上坑比较多,让我们手摸手,一起走…… 以下是一些学习 UiPath 和 RPA 的资源, 拿走不用谢! UiPath Studio 中文文档 机器人流程自动化其实是很好的概念和技术, ...

  6. [转]操作系统Unix、Windows、Mac OS、Linux的故事

    [写得很江湖气,可惜找不到原作者了] 文章转自:http://blog.csdn.net/wenmingchan/article/details/49925379 http://www.jb51.ne ...

  7. jmeter接口测试实例:带参数、带token

      测试内容简介: 1.get请求,无参数 2.get请求,参数为第一条响应中的id 3.get请求,带token 结构图:     下面进行详解: 一.添加cookie管理器等     1.添加ht ...

  8. Phaser3让超级玛丽实现轻跳、高跳及加上对应的跳跃声音

      mario jumper 在线测试地址:http://www.ifiero.com/uploads/phaserjs3/jumper/ 空格键:轻按:跳低 ,长按:跳高键盘:--> 向右 , ...

  9. java.util.MissingResourceException: Can't find bundle for base name init, locale zh_CN问题的处理

    一.问题描述 项目开发使用的是SSM框架,项目那个正常运行,开发一个新功能后,添加了一些配置文件,再重新运行项目抛出异常,找不到name为init的bean. 二.异常信息详细 六月 30, 2018 ...

  10. 【ZABBIX】ZABBIX3.2升级3.4

    小贴士 1.停止zabbix服务 service zabbix_server stop service zabbix_agentd stop /usr/local/zabbix/sbin/zabbix ...