HiveQL:视图
2016-04-20 18:07
309 查看
使用视图来降低查询复杂度
当查询变得很长或复杂的时候,通过使用视图将这个查询语句分隔成多个小的、更可控的片段可以降低这种复杂度。
eg:
from ( select * from people join cart on (cart.people_id=people.id) where firstname='john') a select a.lastname where a.id=3 ;
可以将嵌套子查询变成一个视图:
create view shorter as select * from people join cart on (cart.people_id=people.id) where firstname='john' ;
使用视图来限制基于条件过滤的数据
对于视图来说一个常见的使用场景就是基于一个或多个列的值来限制输出结果。有些数据库允许将视图作为一个安全机制,也就是不给用户直接访问具有敏感数据的原始表,而是提供给用户一个通过where字句限制了的视图,以供访问。
eg:
create table emp (firstname string,lastname string,ssn string,pwd string,depart string) ;
create view mid_emp as select firstname,lastname,ssn from emp where depart='0908' ;
动态分区中的视图和map类型
create view orders(state,city,part) as select cols['state'],cols['city'],cols['part'] from dynamictable where cols['type']='request' ;
视图零零碎碎相关的事情
create view if not exists ship(time,part)
commont '...'
tblproperties('creator'='me')
as select ...
create table ship2 like ship ;
drop view if exists ship ;
alter view ship set tblproperties('created_at'='some_timestamp');
当查询变得很长或复杂的时候,通过使用视图将这个查询语句分隔成多个小的、更可控的片段可以降低这种复杂度。
eg:
from ( select * from people join cart on (cart.people_id=people.id) where firstname='john') a select a.lastname where a.id=3 ;
可以将嵌套子查询变成一个视图:
create view shorter as select * from people join cart on (cart.people_id=people.id) where firstname='john' ;
使用视图来限制基于条件过滤的数据
对于视图来说一个常见的使用场景就是基于一个或多个列的值来限制输出结果。有些数据库允许将视图作为一个安全机制,也就是不给用户直接访问具有敏感数据的原始表,而是提供给用户一个通过where字句限制了的视图,以供访问。
eg:
create table emp (firstname string,lastname string,ssn string,pwd string,depart string) ;
create view mid_emp as select firstname,lastname,ssn from emp where depart='0908' ;
动态分区中的视图和map类型
create view orders(state,city,part) as select cols['state'],cols['city'],cols['part'] from dynamictable where cols['type']='request' ;
视图零零碎碎相关的事情
create view if not exists ship(time,part)
commont '...'
tblproperties('creator'='me')
as select ...
create table ship2 like ship ;
drop view if exists ship ;
alter view ship set tblproperties('created_at'='some_timestamp');
相关文章推荐
- HiveQL:索引
- [置顶] [汇编语言学习笔记][第七章更灵活的定位内存的方法]
- Leetcode_338_Counting Bits
- [汇编语言学习笔记][第七章更灵活的定位内存的方法]
- urllib2模块 异常处理
- LeetCode 313 Super Ugly Number
- Android Selector 与 Shape 基本用法
- HCatalog
- iOS-金额小写转大写
- Eclipse开发web项目中关于HttpServletRequest包的问题
- 害人的VS2008,manifest导致“应用程序配置不正确,应用程序未能启动” [转载]
- asp SqlDataSource模糊查询的问题
- CentOS6.5 64位环境下安装Mysql
- 离散小波变换(DWT)整理
- 如何利用Node.js 构建分布式集群
- 国内有哪些好的刷题网站?
- 自定义Hive文件和记录格式
- Hive函数
- vijos P1352 最大获利(最小割)
- iOS Xcode6添加pch文件