create table index_tmp(id int,name string,dt string) row format delimited fields terminated by ',' stored as textfile;
load data local inpath '/usr/local/hivelog/index.txt' into table index_tmp;
partition模式为不严谨
set hive.exec.dynamic.partition.mode=nonstrict;
打开动态partition
set hive.exec.dynamic.partition=true;
insert overwrite table index_test partition(dt) select id,name,dt from index_tmp;
创建索引表
create index index_dom01 on table index_test(id) as 'org.apache.hadoop.hive.ql.index.compact.CompactIndexHandler' with deferred rebuild;
alter index index_dom01 on index_test rebuild;
查看索引
show index on index_test;
删除索引
drop index index_dom01 on index_test;