码迷,mamicode.com
首页 > 其他好文 > 详细

2、hive的基本操作

时间:2017-07-20 18:54:57      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:基本操作   logs   file   use   str   int   field   lin   store   

1、创建表

 hive>CREATE TABLE userTables(id INT,name STRING);

 

或者

hive> CREATE TABLE userTables(id int, name string) ROW FORMAT DELIMITED FIELDS TERMINATED BY   LINES TERMINATED BY \n STORED AS TEXTFILE;

 

其中TERMINATED BY ‘ ‘指定了数据分隔符是一个空格

创建一个新表,结构与其他一样
hive> create table new_table like testUser;

2、创建分区表
hive> create table logs(ts bigint,line string) partitioned by (dt String,country String)ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘ ‘ LINES TERMINATED BY ‘\n‘ STORED AS TEXTFILE;

加载分区表数据:

hive> load data local inpath ‘/home/test.txt‘ into table logs partition (dt=‘2017-07-20‘,country=‘GB‘);
 

  

 

 

2、hive的基本操作

标签:基本操作   logs   file   use   str   int   field   lin   store   

原文地址:http://www.cnblogs.com/royfans/p/7212646.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!