HiveSQL DQL :DISTRIBUTE BY、CLUSTER BY、Sort By、Order By

3.DQL

3.1脚本模板

SELECT [DISTINCT] select_expr, select_expr, ...
FROM table_reference [WHERE where_condition]
[GROUP BY col_list [HAVING condition]] 
[ CLUSTER BY col_list | [DISTRIBUTE BY col_list] [SORT BY| ORDER BY col_list] ]
[LIMIT number]

DISTRIBUTE BY col_list
以指定字段作为 key 作 hash partition,保证相同的 key会到同一个reduce 去处理。
Sort By col_list
以指定字段作为单个 reduce 排序的 key,保证单个reduce 内的 key 有序排列输出。
Order By col_list
只会生成一个 reduce 任务,对全部排序
CLUSTER BY col_list
以指定字段作为 key 做 hash partition,保证相同 key 会到同一个reduce 去处理。该命令相当于 distributed by col_list 和 sort by col_list 的联合使用。
3.2典型样例
查询所有记录

select * from student;

加入 where 查询条件

select * from student where id=‘001’;

加入 limit 限制

select * from student where id='001' limit 3;

升降序:

select * from student where id='001' order by come_date desc limit 3;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值