index index

1. Create a table

drop table if exists kg_fk_user;
create table kg_fk_user(
id int,
name string
)
row format delimited
fields terminated by ","
stored as textfile;

2. 创建索引
create index user_index on table kg_fk_user(id)
as "org.apache.hadoop.hive.ql.index.compact.CompactIndexHandler"
with deferred rebuild
in table kg_fk_user_index;

3. 显示索引
hive> show formatted index on kg_fk_user;

idx_name      tab_name       col_names      idx_tab_name            idx_type        comment
user_index    kg_fk_user             id           kg_fk_user_index       compact

 

4. rebuild the index

alter index user_index on kg_fk_user rebuild;

5. Delete Index

drop index if exists user_index on  kg_fk_user

Guess you like

Origin www.cnblogs.com/hapyygril/p/11114562.html