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;

  • 相关阅读:
    Project Euler 389 Platonic Dice (概率)
    单纯形(相关题目)
    关于C++中的内存泄露
    莫比乌斯反演与积性函数求和筛法中的一些细节
    清华集训2015-Day 2
    bzoj3456-城市规划
    多项式运算的一些技术
    bzoj2302-Problem c
    bzoj4300-绝世好题
    bzoj4726-Sabota?
  • 原文地址:https://www.cnblogs.com/MrFee/p/hive_index.html
Copyright © 2011-2022 走看看