分区表:
在大数据中,最常用的一种思想就是分治,我们可以把大的文件切割划分成一个个的小的文件,这样每次操作一个小的文件就会很容易了,同样的道理,在hive当中也是支持这种思想的,就是我们可以把大的数据,按照每天,或者每小时进行切分成一个个的小的文件,这样去操作小的文件就会容易得多了。
创建分区表语法:
create table order_partition(
order_no string,
event_time string
)
PARTITIONED BY(event_month string)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t';
加载数据到分区:
load data local inpath '/home/hadoop/data/order.txt' overwrite into table order_partition
PARTITION (event_month='2014-05');
修改表,进行手动添加方式:
ALTER TABLE order_partition ADD IF NOT EXISTS PARTITION (event_month='2014-06') ;
多分区表:
create table order_mulit_partition(
order_no string,
event_time string
)
PARTITIONED BY(event_month string, step string)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t';
load data local inpath '/home/hadoop/data/order.txt' overwrite into table