文章目錄
- hive索引
- 建立索引
- 加載索引資料
- 檢視索引表中資料
- 删除索引
- 檢視索引
- 參考
索引是hive0.7之後才有的功能,建立索引需要評估其合理性,因為建立索引也是要磁盤空間,維護起來也是需要代價的
create index idx_user_phone on table user_phone_with_phone_message(user_phone)as 'org.apache.hadoop.hive.ql.index.compact.CompactIndexHandler'with deferred rebuildIN TABLE idx_user_phone_with_phone_message;idx_user_phone: 索引名字
user_phone_with_phone_message:要建立索引的原始表
user_phone:索引字段
idx_user_phone_with_phone_message:建立索引後的表
org.apache.hadoop.hive.ql.index.compact.CompactIndexHandler :建立索引需要的實作類
alter index idx_user_phone on user_phone_with_phone_message rebuild;idx_user_phone:建立索引後的表
user_phone_with_phone_message:要建立索引的原始表
select * from idx_user_phone_with_phone_message;
drop index idx_user_phone on user_phone_with_phone_message;
show index on user_phone_with_phone_message