标签:for str row 三十八 否则 rmi 互相连接 语句 优化
hive (default)> select e.empno, e.ename, d.deptno, d.dname from emp e join dept
d on e.deptno = d.deptno;
hive (default)> select e.empno, e.ename, d.deptno from emp e join dept d on e.deptno
= d.deptno;
hive (default)> select e.empno, e.ename, d.deptno from emp e join dept d on e.deptno
= d.deptno;
hive (default)> select e.empno, e.ename, d.deptno from emp e left join dept d on
e.deptno = d.deptno;
hive (default)> select e.empno, e.ename, d.deptno from emp e right join dept d on
e.deptno = d.deptno;
hive (default)> select e.empno, e.ename, d.deptno from emp e full join dept d on
e.deptno
= d.deptno;
create table if not exists location(
loc int,
loc_name string
)
row format delimited fields terminated by ‘\t‘;
hive (default)> load data local inpath ‘/opt/module/datas/location.txt‘ into table
location;
hive (default)>SELECT e.ename, d.dname, l.loc_name
FROM emp e
JOIN dept d
ON d.deptno = e.deptno
JOIN location l
ON d.loc = l.loc;
hive (default)> select empno, dname from emp, dept;
hive (default)> select e.empno, e.ename, d.deptno from emp e join dept d on e.deptno
= d.deptno or e.ename=d.ename; 错误的
(1)查询员工信息按工资升序排列
hive (default)> select * from emp order by sal;
(2)查询员工信息按工资降序排列
hive (default)> select * from emp order by sal desc;
hive (default)> select ename, sal*2 twosal from emp order by twosal;
hive (default)> select ename, deptno, sal from emp order by deptno, sal ;
1.设置 reduce 个数
hive (default)> set mapreduce.job.reduces=3;
2.查看设置 reduce 个数
hive (default)> set mapreduce.job.reduces;
3.根据部门编号降序查看员工信息
hive (default)> select * from emp sort by deptno desc;
4.将查询结果导入到文件中(按照部门编号降序排序)
hive (default)> insert overwrite local directory ‘/opt/module/datas/sortbyresult‘
select * from emp sort by deptno desc;
hive (default)> set mapreduce.job.reduces=3;
hive (default)> insert overwrite local directory ‘/opt/module/datas/distributeresult‘ select * from emp distribute by deptno sort by empno desc;
hive (default)> select * from emp cluster by deptno;
hive (default)> select * from emp distribute by deptno sort by deptno;
Hive基础(三十八):Hive DML (二) JOIN/排序
标签:for str row 三十八 否则 rmi 互相连接 语句 优化
原文地址:https://www.cnblogs.com/qiu-hua/p/14877898.html