zoukankan      html  css  js  c++  java
  • Hive索引的操作

      源表:

      create table bak(name string,id string,phone string,card_num bigint,email string,addr string) partitioned by (time string)row format delimited fields terminated by ',';

      load data local inpath '/home/xfvm/bak' into table bak partition(time='2017-10-17');

      1、创建索引(分区字段自动创建索引)

      create index bak_index on table bak(id,name) as 'org.apache.hadoop.hive.ql.index.compact.CompactIndex' deferred rebuild in table bak_index_table;

      2、显示索引

      show formatted index on bak;

       3、重建索引(当表中添加新字段且新字段需要创建索引时)

      (1)源表添加字段

       alter table bak add columns (country string,city string);

      (2)索引表重新建

      create index bak_index on table bak(id,name,country) as 'org.apache.hadoop.hive.ql.index.compact.CompactIndexHandler' with deferred rebuild in table bak_index_table;

      alter index bak_index on bak rebuild;

      查看索引表的数据

      4、删除索引

      drop index  if exists bak_index on bak;

  • 相关阅读:
    Spring 整合 Redis
    Spring 整合 Redis
    C#,Java,MD5加密对等实现
    Java调用JavaWebService
    c#,Java aes加密
    Kettle环境变量配置
    Maven环境配置
    Win10,JDK8,tomact7.0.85配置
    ReverseEngineerCodeFirst 自定义模板
    Aspnet_Session
  • 原文地址:https://www.cnblogs.com/MrFee/p/hive_index.html
Copyright © 2011-2022 走看看