Hive(五)索引、视图、定时器

最近看了一遍hive的文档,本文是为了记录文档中将来会可用东西,并非最全的《文档》,望谅解

一:索引

索引
适用于大多数索引情况:

                  create index table01_index on table table01 (column2) as 'org.apache.hadoop.hive.ql.index.compact.CompactIndexHandler' with deferred rebuild; 

       适用于排序后值比较小情况:

                  create index table01_index on table table01 (column2) as 'bitmap' with deferred rebuild; 

       刷新索引:alter index table02_index on table2 rebuild;

       显示索引:show formatted index on table02;

       删除索引:drop index table02_index on table02;

       分区索引:alter index table10_index on table10 partition (columnx='valueq', columny='valuer') rebuild;;

二:视图

视图
创建视图:create view onion_referrers comment 'referrers to the onion website' as select distinct referrer_url from page_view where page_url='http://www.theonion.com';

       删除视图:drop view if exists onion_referrers; 

       修改视图:alter table view as select *from;   alter table view set tblproperties ('external' = 'true');  

       显示视图:show views in test1 "test_*";        

物化视图(相当于实体表)
创建物化视图:create materialized view onion_referrers comment 'referrers to the onion website' as select distinct referrer_url from page_view where page_url='http://www.theonion.com';

       删除物化视图:drop materialized view onion_referrers;

       刷新物化视图:alter materialized view onion_referrers enable|disable rewrite;

       显示物化视图:show materialized views [in/from database_name] [like 'pattern_with_wildcards’];

三:定时器

定时器
创建定时器:create scheduled query sc1 cron '0 */10 * * * ? *' as insert into t values (1);

                 create scheduled query mv_rebuild cron '0 */10 * * * ? *' defined as alter materialized view mv1 rebuild;

                 create scheduled query ingest every 10 minutes defined as alter materialized view mv1 rebuild;

取消定时器:alter scheduled query t_analyze disable;

查询定时器:select * from information_schema.scheduled_queries s where schedule_name='sc1';

查询定时器结果:select * from information_schema.scheduled_executions s where schedule_name='sc1' order by scheduled_execution_id desc limit 1;

posted @   Kotlin  阅读(225)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
Live2D
点击右上角即可分享
微信分享提示
西雅图
14:14发布
西雅图
14:14发布
4°
东南风
2级
空气质量
相对湿度
92%
今天
3°/12°
周四
4°/11°
周五
2°/10°