软件环境:

linux系统: CentOS6.7
Hadoop版本: 2.6.5
zookeeper版本: 3.4.8

##主机配置:
#####一共m1, m2, m3这三部机, 每部主机的用户名都为centos
```
192.168.179.201: m1
192.168.179.202: m2
192.168.179.203: m3

m1: Zookeeper, Namenode, DataNode, ResourceManager, NodeManager, Master, Worker

m2: Zookeeper, Namenode, DataNode, ResourceManager, NodeManager, Worker

m3: Zookeeper, DataNode, NodeManager, Worker



####资料

官方资料:

https://cwiki.apache.org/confluence/display/Hive/IndexDev

https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-Create/Drop/AlterIndex



---
<br>
<br>
####一. 编辑hive-site.xml文件

hive.optimize.index.filter
true

hive.optimize.index.groupby
true

hive.index.compact.file.ignore.hdfs
true

```










####二. 创建Hive表索引
```
官方资料:
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Indexing
```


1.创建/构造, 显示, 删除索引:

create index table01_index on table table01 (column2) as 'compact';
show index on table01;
drop index table01_index on table01;

2.创建时重构, 格式化显示 (with column names), 删除索引:

create index table02_index on table table02 (column3) as 'compact' with deferred rebuild;
alter index table02_index on table2 rebuild;
show formatted index on table02;
drop index table02_index on table02;

3.创建索引视图, 构建, 显示, 删除:

create index table03_index on table table03 (column4) as 'bitmap' with deferred rebuild;
alter index table03_index on table03 rebuild;
show formatted index on table03;
drop index table03_index on table03;

4.在新表中创建索引:

create index table04_index on table table04 (column5) as 'compact' with deferred rebuild in table table04_index_table;

5.创建索引以RCFile的存储格式:

create index table05_index on table table05 (column6) as 'compact' stored as RCFile;

6.创建索引以TextFile的存储格式:

create index table06_index on table table06 (column7) as 'compact' row format delimited fields terminated by '\t' stored as textFile;

7.创建索引和索引的属性:

create index table07_index on table table07 (column8) as 'COMPACT' idxproperties ("prop1"="value1", "prop2"="value2");

8.创建索引和表的属性:

create index table08_index on table table08 (column9) as 'compact' tblproperties ("prop3"="value3", "prop4"="value4");

9.索引如果存在则删除:

drop index if exists table09_index on table09;

10.重构一个分区的数据:

alter index table10_index on table10 partition (columnX='valueQ', columnY='valueR') rebuild;

Hive扩展功能(八)--表的索引的更多相关文章

  1. hadoop Hive 的建表 和导入导出及索引视图

       1.hive 的导入导出 1.1 hive的常见数据导入方法 1.1.1 从本地系统中导入数据到hive表 1.创建student表 [ROW FORMAT DELIMITED]关键字,是用来设 ...

  2. 十八、dbms_repair(用于检测,修复在表和索引上的损坏数据块)

    1.概述 作用:用于检测,修复在表和索引上的损坏数据块. 2.包的组成 1).admin_tables语法:dbms_repair.admin_tables(table_name in varchar ...

  3. (转)Sql Server之旅——第八站 复合索引和include索引到底有多大区别?

    索引和锁,这两个主题对我们开发工程师来说,非常的重要...只有理解了这两个主题,我们才能写出高质量的sql语句,在之前的博客中,我所说的 索引都是单列索引...当然数据库不可能只认单列索引,还有我这篇 ...

  4. Mysql优化(出自官方文档) - 第八篇(索引优化系列)

    目录 Mysql优化(出自官方文档) - 第八篇(索引优化系列) Optimization and Indexes 1 Foreign Key Optimization 2 Column Indexe ...

  5. hive端建表中文注释乱码

    背景:mysql编码是utf-8,mysql中建库建表中文显示都正常,但在hive窗口中建表时字段中文注释均乱码的问题. 问题:hive中建表后字段中文注释显示异常. 1. 定位 mysql 端问题 ...

  6. python、第八篇:索引原理与慢查询优化

    一 介绍 1. 为何要有索引? 一般的应用系统,读写比例在10:1左右,而且插入操作和一般的更新操作很少出现性能问题,在生产环境中,我们遇到最多的,也是最容易出问题的,还是一些复杂的查询操作,因此对查 ...

  7. Oracle学习笔记八 表空间

    表空间 表空间是一个或多个数据文件的集合,所有的数据对象都存放在指定的表空间中,但主要存放的是表, 所以称作表空间 .   分区表 当表中的数据量不断增大,查询数据的速度就会变慢,应用程序的性能就会下 ...

  8. Oracle索引梳理系列(五)- Oracle索引种类之表簇索引(cluster index)

    版权声明:本文发布于http://www.cnblogs.com/yumiko/,版权由Yumiko_sunny所有,欢迎转载.转载时,请在文章明显位置注明原文链接.若在未经作者同意的情况下,将本文内 ...

  9. Lucene学习之一:使用lucene为数据库表创建索引,并按关键字查询

    最近项目中要用到模糊查询,开始研究lucene,期间走了好多弯路,总算实现了一个简单的demo. 使用的lucene jar包是3.6版本. 一:建立数据库表,并加上测试数据.数据库表:UserInf ...

随机推荐

  1. noip模拟赛 天天和不可描述

    分析:直接就这么翻肯定是不行的,换一种想法:有括号就是把括号里的字符串倒着输出,如果在括号里又遇到了括号就继续倒着输出,相当于递归. 我们可以用递归直接做,也可以用一层循环搞定,每次从左括号跳到右括号 ...

  2. hdu 1853 KM算法

    #include<stdio.h> #include<math.h> #include<string.h> #define N 200 #define inf 99 ...

  3. Python - 对多继承以及super的一些了解

    Python支持多继承,与C++一样都会出现一种问题:子类继承的多个父类又继承了同一个父类,这时就有可能会出现父类构造方法被调用多次的情况.关于这个问题,我找了一些资料,虽然没有亲自全部验证,这里我总 ...

  4. 实例:Mongodb集群配置过程

    最近因为一些项目公司开始采用Mongodb做为大量的数据存储,通过网络上大量的资源自己已经掌握一套可行的Mongodb集群配置过程,Mongodb具有无规则存储.大数据存储.多平台支持.强大的扩展插件 ...

  5. AbstractList 重写 equals() 方法

    题目内容 题目内容很简单,就是创建 ArrayList 和 Vector 集合,向两者添加相同内容的字符串,最后用 equals() 方法比较是否相等. 这里就考察了 "==" 和 ...

  6. VB的程序如何破解

    VB的程序,不会告诉你这个VB写的,但是从界面来看就很像VB,一般是单文件的EXE,然后软件还比较小(早期的傻瓜式软件写的东西)   比如说我们想要知道这个"手动采集"按钮干了什么 ...

  7. Java Map 怎样实现Key 的唯一性?

    大家都知道.在Map和Set不可存在反复元素? 可是对于内部的细节我们并不了解.今天我们就一块来 探讨一下! 1 对于 HashMap  HashSet 他们的底层数据结构的实现是:维护了一张  Ha ...

  8. Servlet-SrpingMVC 生成验证码

    在SpringMVC中配置生成验证码: import org.springframework.stereotype.Controller; import org.springframework.web ...

  9. Parallel and Perpendicular

    题目链接 题意: 输入n,求正n边形中的对角线1和对角线2的个数(对角线1:至少与其它一个对角线平行:对角线2:至少与其它一个对角线垂直).对角线不能是多边形的边 (4 ≤ n ≤ 10e5) 分析: ...

  10. la3211

    2-sat+二分... 每次二分答案然后连边2-sat...边要开到n*n 样例水得跟没有一样... #include<bits/stdc++.h> using namespace std ...