asc:升序(默认升序) desc:降序
全局排序(order by)
只有一个reducer
select id,name from table_name order by id asc;
局部排序(sort by)
在每个Reducer内部进行排序,全局并不是有序的 需要设置mapReduce的数量set mapreduce.job.reduce=3;
select id,name from table_name sort by id asc;
分区排序(distribute by + sort by OR cluster by)
相当于MR中partition分区
insert overwrite local directory '/home/hduser/software/hive_1.2.1/export_data' select * from emp distribute by dept_id sort by dept_id
;
insert overwrite local directory '/home/hduser/software/hive_1.2.1/export_data' select * from emp cluster by dept_id
;
|