1.创建customer表格(IDname date)
2.下载数据
3.设置静态分区(a创建分区表,使用name列作为分区
b.对name=Arthur创建静态分区)
4.动态分区
create table if not exists Customer(id string,name string,date1 string)
row format delimited fields terminated by’,’
lines terminated by’\n’ stored as textfile;
load data local inpath’/tools/datafiles/customer.txt’into table Customer;
create table if not exists part_customer (id string,date1 string)
partitioned by (name string) row format delimited fields terminated by’,’
lines terminated by’\n’stored as textfile;
insert into table part_customer partition (name = ‘Arthur’) select id,date1 from customer
where name = ‘Arthur’;
create table if not exists dyna_part_customer (id string,name string,date1 string) partitioned by (name string) row format delimited fields terminated by’,’ lines terminated by’\n’stored as textfile;
insert into table dyna_part_customer partition (name) select id,name,date1 from customer;
alter table dyna_part_cuatomer drop partition (name = ‘Arthur’);