本文共 626 字,大约阅读时间需要 2 分钟。
分区通过partition by(字段名 字段类型) - 分区最后会形成一个目录。分区的字段,不在源数据中出现,但是表的一部分创建一个分区表hive> create table stud01( id string, name string, age int )partitioned by (grade string)row format delimitedfields terminated by '\t';创建多级目录hive> create table stud01( id string, name string, age int )partitioned by (create_year string,create_month string)row format delimitedfields terminated by '\t';导入数据在导入数据时,通过partition提定分区的值:hive> load data local inpath '${env:HOME}/stud.txt' into table stud01 partition(grade='2009');查看分区hive>show partitions stu01;查询分区数据select * from AccountRegister where create_date="2014-10-1";
转载地址:http://csazi.baihongyu.com/