1.Hive分区表
Hive使用select语句进行查询的时候一般会扫描整个表内容,会消耗很多时间做没必要的工作。Hive可以在创建表的时候指定分区空间,这样在做查询的时候就可以很好的提高查询的效率。
创建分区表的语法:
create table tablename(
name string
)partitioned by(key,type...);
示例
drop table if exists employees;
create table if not exists employees(
name string,
salary float,
subordinate array<string>,
deductions map<string,float>,
address struct<street:string,city:string,num:int>
) partitioned by (date_time string,type string)
row format delimited fields terminated by '\t'
collection items terminated by ','
map keys terminated by ':'
lines terminated by &