导入数据到hive中
create external table xiyouji(line string) 建立外部表西游记
location
'hdfs://localhost:9000/hive_wordcount; 定位hdfs中数据来源
将各词汇装进word_count表中,以空格划分
create table word_count as
select word,count(1) as count from
(select explode(split(line,''))as word from xiyouji) w
group by word
order by word;
若以排序方式输出
create table word_count1 as
select word,count(1) as count from
(select explode(split(line,''))as word from xiyouji) w
group by word
order by count;