天天看点

关于hive数据导入方式的总结

从本地导入数据到hive:

load data local inpath '/home/hive/tb_dw_cu_three_type_list_dtal/*.dat' overwrite into table csap.tb_dw_cu_three_type_list_dtal  partition(statis_date=20160121);

从hdfs直接导入数据到hive:

load data inpath '/hadoop/interface/renadata/aol_open_call_log_*_201602_20160215.dat' into table csap.tb_ods_ct_rena_open_call_log_all_day partition(statis_date=20160215);

请注意load data inpath ‘/home/wyp/add.txt’ into table

wyp;里面是没有local这个单词的,这个是和本地的区别。

从一个表中导数据到另一张表:

insert into table test partition (age='25')

select id, name, tel from wyp;

hive支持多表插入:

from wyp

insert into table test partition(age)

select id, name, tel, age

insert into table test3

select id, name where age>25;

注意:传统数据块的形式insert into table values(字段1,字段2),这种形式hive是不支持的。

分区:在hive中,表的每一个分区对应表下的相应目录,所有分区的数据都是存储在对应的目录中。

装载数据相当于把之前hdfs上的数据移动到hive对应的目录下。