Hive索引的操作

2022-03-28 05:25:24 字數 1152 閱讀 6404

源表:

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、顯示索引

3、重建索引(當表中新增新字段且新字段需要建立索引時)

(1)源表新增字段

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

(2)索引表重新建

檢視索引表的資料

4、刪除索引

drop index  if exists bak_index on bak;

hive 建立索引

索引是hive0.7之後才有的功能,建立索引需要評估其合理性,因為建立索引也是要磁碟空間,維護起來也是需要代價的 create index idx user phone on table user phone with phone message user phone as org.apache.h...

hive 建立索引

索引是hive0.7之後才有的功能,建立索引需要評估其合理性,因為建立索引也是要磁碟空間,維護起來也是需要代價的 create index idx user phone on table user phone with phone message user phone as org.apache.h...

hive的資料操作

1.向表中裝載資料 load data local inpath california employees overwrite into table employees partition country us state ca 2.通過查詢語句向表中插入資料 insert overwrite in...