1、创建表
1.1、直接将一个表里的字段查出来放到新建的表中,字段hive会自动建好。
create table temp_table stored as rcfile as
select
id, name, age, school
from table1
where id=xxx;
1.2、将表字段创建好,根据性别和省份分区,(分区字段不用写到字段里)
create table temp_table1 (
id string,
name string,
age string,
school string,
)
partitioned by (gander string, prvnce string);
2、向表中插入数据
2.1、直接插入(注:overwrite会覆盖以前的数据,into不会覆盖以前的数据,具体使用时根据情况选择。)
INSERT overwrite(into) temp_table1 PARTITION (gander,prvnce)
select
id,name,age,school,gander,prvnce
from table1;
2.2、从本地文件中导入数据
#创建目标表,字段根据你文件字段对应创建
create table temp_table2(
license_number string
enterprise_name string
ds string
accs_nbr1 string