关于Hive建表,参考官网:
-
weblog
表结构:
CREATE TABLE IF NOT EXISTS weblog(
ip string ,
time string ,
req_url string ,
status string ,
size string
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' ;
- 数据如下:
61.135.216.104 [25/Sep/2013:00:10:10 +0800] "GET /search-engine/thrift-framework-intro/feed/ HTTP/1.1" 304 160
175.42.93.145 [25/Sep/2013:00:10:11 +0800] "GET /mapreduce/hadoop-rumen-introduction HTTP/1.1" 301 427
175.42.93.145 [25/Sep/2013:00:10:12 +0800] "GET /mapreduce/hadoop-rumen-introduction/ HTTP/1.1" 200 20875
-
导入数据
load data local inpath '/home/hadoop/data/weblog' into table weblog ;
也可以像下面这样建表
create table weblog_1 as select ip,time,req_url from weblog; 启动了MR任务
create table weblog_2 like weblog;