Hive SQL使用指南(4)——检索数据 2015-05-07 22:00

高级查询

  • 这也行
1
FROM people SELECT *;
  • GROUP BY
1
SELECT COUNT(1) AS Num FROM student GROUP BY name;
  • JOIN
1
SELECT p.id AS ID,p.name AS Name,a.city AS City FROM people p JOIN place a ON (p.id = a.id);
  • MULTITABLE INSERT
1
2
3
4
FROM people
INSERT OVERWRITE TABLE dest1 SELECT people.* WHERE people.id > 203
INSERT OVERWRITE TABLE dest2 SELECT people.* WHERE people.id < 105
INSERT OVERWRITE LOCAL DIRECTORY '/tmp/test/new_out' SELECT people.* WHERE people.id=202;

同时往三个表/目录插入数据。

Tags: #Hive    Post on Hadoop