Hive建表

关于Hive建表,参考官网:

https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-ManagedandExternalTables

  • 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' ;  

《Hive建表》 hive建表.png

  • 数据如下:
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 ;

    《Hive建表》 image.png

  • 也可以像下面这样建表

create table weblog_1 as select ip,time,req_url from weblog; 启动了MR任务
create table weblog_2 like weblog;

《Hive建表》 image.png

    原文作者:sparkle123
    原文地址: https://www.jianshu.com/p/13600f74f96f
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞