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. Nginx入门篇(七)之Nginx+keepalived高可用集群

    一.keepalived介绍 keepalived软件最开始是转为负载均衡软件LVS而设计,用来管理和监控LVS集群系统中各个服务节点的状态,后来又加入了可实现高可用的VRRP功能.所以Keepali ...

  2. Java构造方法与析构方法实例剖析

    Java构造方法 类有一个特殊的成员方法叫作构造方法,它的作用是创建对象并初始化成员变量.在创建对象时,会自动调用类的构造方法. 构造方法定义规则:Java 中的构造方法必须与该类具有相同的名字,并且 ...

  3. stl源码分析之allocator

    allocator封装了stl标准程序库的内存管理系统,标准库的string,容器,算法和部分iostream都是通过allocator分配和释放内存的.标准库的组件有一个参数指定使用的allocat ...

  4. static和构造函数初始化顺序

    abstract class demo{ public demo() {} protected void a() { System.out.println("I am parents!&qu ...

  5. Unity利用Share SDK实现QQ、微信及微博第三方登录及定制内容分享(附代码)

    最近因为公司的项目需要添加一些实用性的功能,需要添加第三方登录及分享,采用的是Mob的SDK,可以先到其官网下载对应的SDK 点击这里,为了方便后期进行数据统计和分析,所以可以先添加一个应用,添加成功 ...

  6. web _service 接口

    1.WebService 就是 http请求    post接口 2.需要加 请求头信息 Content-Type: text/xml; 3.需要把占位符换成需要的字符串 webservice接口可以 ...

  7. Boss直聘邮件通知小脚本

    Boss 基于Python3的找工作利器--Boss直聘来消息邮件通知, 自动发送简历脚本,O(∩_∩)O~ 无聊写的,因为有时候觉得找工作心急如焚,想自动回复自动发简历啊有木有~~~ github地 ...

  8. 基于C#的机器学习--机器学习的基本知识

    机器学习的基本知识 ,…用n个观测值测量.但我们不再对Y的预测感兴趣,因为我们不再有Y了,我们唯一感兴趣的是在已有的特征上发现数据模式: ​ 在前面的图中,我们可以看到这样的数据本身更适合于非线性方法 ...

  9. jupyter通过notedown使用markdown

    0 Problem 最近看了下李沐老师的mxnet教程,在使用jupyter的时候打开教程发现全是markdown源文,没有展示markdown格式的文字. 1 Reason 源代码是用markdow ...

  10. Action Required: Please provide your Tax Identity Information - Amazon Seller Tax Identity Collection

    Hello ***,   Your selling privileges have been suspended because we have not received required tax i ...