hive系列(一)
来源:互联网 发布:java与xml数据绑定 编辑:程序博客网 时间:2024/06/06 00:00
1 hive简介
Hive是一个构建在Hadoop上的数据仓库工具,目标是SQL与MR的映射。hive十分适合数据仓库的统计分析。
Hive在hadoop生态系统中扮演数据仓库的角色,将结构化的数据文件映射成一张数据库中的表;
2 hive与HBase的关系
hive和HBase都是构建在hadoop之上的技术;HBase是一个key/value的非关系型数据库,运行在HDFS之上;Hive是运行在HDFS之上的数据仓库;
Hive适用于对一段时间内数据进行离线处理分析,运行比较慢,不适合实时查询;
HBase适用大数据库的实时查询;
Hive、HBase、HDFS三者数据可以相互迁移;
3 创建数据库
hive> create database hive;
hive> use hive;4 创建内部表 hive> create table emp( > empno int, > empname string, > job string, > mgr int, > hiredate string, > salary double, > comm string, > deptno int ) > row format delimited > fields terminated by " "; [root@localhost hive]# cat input.txt hive> load data local inpath '/usr/local/hive/input.txt' overwrite into table emp; hive> select * from emp; 此时会在input.txt同级目录下产生一个emp.java,该文件是sql转换成mapreduce文件5 创建外部表采用pig客户端创建目录grunt> mkdir /hivehive> create external table emp_ext( > empno int, > empname string, > job string, > mgr int, > hiredate string, > salary double, > comm string, > deptno int ) > row format delimited > fields terminated by " " > location '/hive';hive> select count(1) from emp_ext;0说明没有数据利用pig向/hive中添加一个文件grunt> copyFromLocal /usr/local/input.txt /hive/input.txthive> select * from emp_ext;6 创建分区表 hive> create table emp_part( > empno int, > empname string, > job string, > mgr int, > hiredate string, > salary double, > comm string, > deptno int) > partitioned by (year string,month string) > row format delimited > fields terminated by " ";hive> load data local inpath '/usr/local/hive/input.txt' into table emp_part partition (year='2016',month='10');7 其它创建表的方式hive> create table emp_part like default.emp_part;hive> create table emp_part as default.emp_part;
0 0
- hive系列(一)
- HIVE学习系列笔记 一(精简版)
- hive系列(二)
- hive系列(1)
- hive 资料整理系列一 入门
- 1.1-Hive入门(Hive系列)
- Hive 操作(一)
- hive学习(一)
- hive基础知识(一)
- Hive学习指南(一)
- hive(一)
- hive基础(一)
- Hive(一)
- hive系列(3)---Transform
- Hive随谈(一):Hive入门
- Hive 随谈(一)– Hive 入门
- Hive 随谈(一)– Hive 入门
- Hive总结(一)hive初始
- Hadoop加zookeeper搭建高可靠集群
- OpenGL ES入门
- java.lang.AbstractMethodError: javax.servlet.jsp.JspFactory.getJspApplicationContext(Ljavax/servlet/
- ubuntu安装zabbix server和agent的一些问题
- 求Sn=1!+2!+3!+4!+5!+…+n!之值,其中n是一个数字
- hive系列(一)
- 搭建android应用开发环境
- 算法系列(一)最大子数列问题
- linux关闭正在运行在后台的程序
- Flash在线拍照
- ecshop小京东模板切换到smarty3.13之模板函数,用模板函数替换楼层
- linux shell 安装模块自动跳过确认
- 使用 Maven Profile 和 Filtering 打各种环境的包
- MSP430G2553 flash操作例子