码迷,mamicode.com
首页 > 其他好文 > 详细

hive:创建索引

时间:2017-10-22 11:03:11      阅读:229      评论:0      收藏:0      [点我收藏+]

标签:hive   store   插入   div   情况下   mina   show   apache   create   

hive也是支持索引的使用,但是如果表中已经有数据的情况下,创建索引的过程不是特别快。

已经拥有表:

create table if not exists llcfpd_withgroupbykey(groupbykey string,lrp string,timestamp string,objid string,uid string) 
row format delimited fields terminated by , stored as textfile;

创建索引:

create index idx_llcfpd_withgroupbykey on table llcfpd_withgroupbykey(groupbykey)
as org.apache.hadoop.hive.ql.index.compact.CompactIndexHandler 
with deferred rebuild
IN TABLE llcfpd_withgroupbykey_idx;

备注:需要注意这里边创建索引实际上是插入了特定的数据到一个表。

原表更新数据:

ALTER INDEX idx_llcfpd_withgroupbykey on llcfpd_withgroupbykey REBUILD;

备注:当表中已经拥有数据的情况下,必须执行该语句,否则索引没有起到效果。

删除索引:

DROP INDEX idx_llcfpd_withgroupbykey on llcfpd_withgroupbykey;

查看索引:

SHOW INDEX on llcfpd_withgroupbykey;

 

hive:创建索引

标签:hive   store   插入   div   情况下   mina   show   apache   create   

原文地址:http://www.cnblogs.com/yy3b2007com/p/7707580.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!