0
点赞
收藏
分享

微信扫一扫

hive 创建索引

桑二小姐 2022-02-16 阅读 67



文章目录


  • ​​hive索引​​

  • ​​创建索引​​
  • ​​加载索引数据​​
  • ​​查看索引表中数据​​
  • ​​删除索引​​
  • ​​查看索引​​
  • ​​参考​​



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 rebuild
IN 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

参考

​​创建索引​​



举报

相关推荐

0 条评论