hive> create table textlines(line string);
hive> load data local inpath ‘/Users/lihu/Desktop/crawle/wahah.txt‘ into table textlines;
hive> select * from textlines;
hive> create table words(word STRING);
hive> insert overwrite table words select explode(split(line, ‘ ‘)) word form textlines;
hive> SELECT word,count(1) FROM words GROUP BY word ORDER BY word;
hive> insert overwrite local directory ‘/Users/lihu/Desktop/crawle/wordcount_result‘ row format delimited fields terminated by ‘\t‘ SELECT word,count(1) FROM words GROUP BY word ORDER BY word;
hive> create table wyp (id int, name string, age int, tel string) ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘\t‘ STORED AS TEXTFILE;
hive> load data local inpath ‘/Users/lihu/Desktop/crawle/heihei.txt‘ into table wyp;
hive> insert overwrite local directory ‘/Users/lihu/Desktop/crawle/wyp‘ row format delimited fields terminated by ‘\t‘ select * from wyp;
hive> select author, sum(numberread),count(1) from taperr;
hive> create table tap (title string, author string, numberread int, url string) ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘ ‘ STORED AS TEXTFILE;
原文:http://www.cnblogs.com/sunyaxue/p/6362570.html