目录
[2、 数据映射](#2、 数据映射)
[3、Liket 和 Rlike](#3、Liket 和 Rlike)
一、准备文件
1、创建表
准备两个文件emp.txt和dept.txt
创建表(在hive上操作) ,先进入itcast 命令:
use itcast;
create table emp(empno int,ename string,job string,mgr int,hiredate string,sal double,comm double,deptno int)row format delimited fields terminated by '\t';
create table dept(deptno int,dname string,loc int) row format delimited fields terminated by '\t';
2、 数据映射
创建表完成后,将数据文件移动到对应的HDFS路径下,完成数据映射。
二、HIVE的数据操作
1、基本查询
a、全表查询
select * from emp;

b、选择特定字段查询
select deptno,dname from dept;

c、查询员工表总人数
select count(*) cnt from emp;

d、查询员工表总工资额
select sum(sal) sum_sal from emp;

e、查询5条员工表的信息
select * from emp limit 5;

2、Where条件查询
a、查询工资等于5000的所有员工
select * from emp where sal=5000;

b、查询工资在500到1000的员工信息
select * from emp where sal between 500 and 1000;

c、查询comm为空的所有员工信息
select * from emp where comm is null;

d、查询工资是1500和5000的员工信息
select * from emp where sal IN (1500,5000);
3、Liket 和 Rlike
a、查找工资以2开头的员工信息
select * fcom emp where sal LIKE '2%';

b、查找工资的第二个数值为2的员工信息
hive> select * from emp wheresal LIKE '_2%';

c、查找工资中含有2的员工信息
select * from cmp where sal RLIKE ' [2] ';

此模块分为两篇文章哦,继续学习请参考以下链接:【Hadoop实训】Hive 数据操作②-CSDN博客
