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建表.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 ;

    image.png

  • 也可以像下面这样建表

create table weblog_1 as select ip,time,req_url from weblog; 启动了MR任务
create table weblog_2 like weblog;
image.png
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容