1、在hive中创建索引所在表

create table if not exists h_odse.hxy(
id int,
name string,
hobby array<string>,
add map<string,string>
)
partitioned by (age int,sex string)
row format delimited
fields terminated by ','
collection items terminated by '-'
map keys terminated by ':'
lines terminated by '\n'

2、在服务器内创建数据文件并导入数据

load data local inpath '/home/hetl/data' into table h_odse.hxy partition (age=10,sex='f');

3、从其他表中导入数据

load data local inpath '/home/hetl/data' into table h_odse.hxy partition(age=10,sex='boy') ;

from h_odse.hxy1
insert into h_odse.hxy partition(age,sex)
select id,name,hobby,add,age,sex distribute by age,sex;

4、创建指定索引表的索引

create index hxy_ind on table h_odse.hxy(id) as 'org.apache.hadoop.hive.ql.index.compact.CompactIndexHandler' with deferred rebuild in table h_odse.h_ind_table;

-----当in table h_odse.h_ind_table不加时  系统会自动创建一个索引表

5,使索引生效的话,必须执行

alter index hxy_ind on  h_odse.hxy rebuild;

6,测试索引效果

select * from h_odse.hxy where id=1

未加索引时:

Time taken: 0.676 seconds, Fetched: 24 row(s)

添加索引后:

Time taken: 0.494 seconds, Fetched: 24 row(s)

7,、查询当前表中有哪些索引

use h_odse;

show index on hxy;

8、删除索引

drop index hxy_ind on h_odse.hxy;

hive中的索引创建的更多相关文章

  1. Hive中集合类型

    Hive中集合类型 创建表,集合是以 - 分割的 数据文件 加载数据 查询数据 查询数组中第一个字段 再建一个表,使用map 查看数据文件 加载数据 查询数据 查询键值 创建表,struct类型 查看 ...

  2. [转]Oracle 修改或者删除临时表 ORA-14452: 试图创建, 更改或删除正在使用的临时表中的索引

    本文转自:http://blog.csdn.net/treasurelifelhf/article/details/7290729 由于存储过程出现问题,导致前台页面无法显示数据.执行存储过程发现临时 ...

  3. (转载)ORA-14452:试图创建,更改或删除正在使用的临时表中的索引

    因为表kol_xx_fin050_temp 为临时表,而且有其他session正在使用. 处理步骤: 1.先从 dba_objects / user_objects中查询到该表的object_id: ...

  4. ORA-14452: 试图创建, 更改或删除正在使用的临时表中的索引

    ORA-14452: 试图创建, 更改或删除正在使用的临时表中的索引       因为表KOL_XX_FIN050_TEMP 为临时表,而且有其他session正在使用. 处理步骤: 1.先从 dba ...

  5. 在MongoDB中执行查询、创建索引

    1. MongoDB中数据查询的方法 (1)find函数的使用: (2)条件操作符: (3)distinct找出给定键所有不同的值: (4)group分组: (5)游标: (6)存储过程. 文档查找 ...

  6. MySql SqlServer Sqlite中关于索引的创建

    最近要更新Cocon90.Db库,令其ORM创建表时实现索引的添加.因此总结下列常用Sql,供大家学习与参考. 一.SqlServer中创建索引可以这样: ) Create Table Test ( ...

  7. hive中创建表失败

    使用create table命令创建表失败,如下错误信息: hive> create table test(id int,name string,age int,sex string); FAI ...

  8. hive中创建hive-json格式的表及查询

    在hive中对于json的数据格式,可以使用get_json_object或json_tuple先解析然后查询. 也可以直接在hive中创建json格式的表结构,这样就可以直接查询,实战如下(hive ...

  9. 在MongoDB中执行查询与创建索引

    实验目的: (1)掌握MongoDB中数据查询的方法: (2)掌握MongoDB中索引及其创建: 实验内容: 一. MongoDB中数据查询的方法: (1)find函数的使用: (2)条件操作符: a ...

随机推荐

  1. 使用 XSLT 显示 XML

    通过使用 XSLT,您可以向 XML 文档添加显示信息. 使用 XSLT 显示 XML XSLT 是首选的 XML 样式表语言. XSLT (eXtensible Stylesheet Languag ...

  2. PHP+FLASH大文件断点续传功能分享

    1.使用PHP的创始人 Rasmus Lerdorf 写的APC扩展模块来实现(http://pecl.php.net/package/apc) APC实现方法: 安装APC,参照官方文档安装,可以使 ...

  3. CDOJ 1059 秋实大哥与小朋友 STL(set)+离散化+BIT区间更新单点查询

    链接: A - 秋实大哥与小朋友 Time Limit:1000MS     Memory Limit:65535KB     64bit IO Format:%lld & %llu Subm ...

  4. prometheus-pushgateway安装

    背景 当prometheus的server与target不在同一网段网络不通,无法直接拉取target数据,需要使用pushgateway作为数据中转点. 弊端 将多个节点数据汇总到 pushgate ...

  5. Spring Boot教程(八)创建含有多module的springboot工程

    创建根工程 创建一个maven 工程,其pom文件为: <?xml version="1.0" encoding="UTF-8"?> <pro ...

  6. Spark 2.1.1 源码编译

    Spark 2.1.1 源码编译 标签(空格分隔): Spark Spark 源码编译 环境准备与起因 由于线上Spark On Yarn Spark Streaming程序在消费kafka 写入HD ...

  7. java 根据省份证号-判断省份-性别-生日

    package com.nf147.manage.Test; import java.text.ParseException; import java.text.SimpleDateFormat; i ...

  8. OOM和SOF代码

    OutOfMemoryError大数组,例如图片加载. public class MockOutOfMemoryError { public static void main(String[] arg ...

  9. 网站模板-Layui:Layui

    ylbtech-网站模板-Layui:百科 layui,是一款采用自身模块规范编写的前端 UI 框架,遵循原生 HTML/CSS/JS 的书写与组织形式,门槛极低,拿来即用.其外在极简,却又不失饱满的 ...

  10. linux配置ssh公钥认证,打通root用户的免密码输入的scp通道

    1.ssh-keygen ssh-keygen是unix-like系统的一个用来生成.管理ssh公钥和私钥的工具. 2.用法 常用的重要的选项有: -b num   指定生成多少比特长度的key,单位 ...