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

从本地导入数据到hive:

loaddatalocalinpath'/home/hive/tb_dw_cu_three_type_list_dtal/*.dat'overwriteintotablecsap.tb_dw_cu_three_type_list_dtalpartition(statis_date=20160121);

从HDFS直接导入数据到hive:
loaddatainpath'/hadoop/interface/renaData/AOL_OPEN_CALL_LOG_*_201602_20160215.dat'intotablecsap.tb_ods_ct_rena_open_call_log_all_daypartition(statis_date=20160215);
 
请注意load data inpath ‘/home/wyp/add.txt’ into table wyp;里面是没有local这个单词的,这个是和本地的区别。
 
从一个表中导数据到另一张表:
insertintotabletestpartition(age='25')
selectid,name,telfromwyp;
 
hive支持多表插入:
fromwyp
insertintotabletestpartition(age)
selectid,name,tel,age
insertintotabletest3
selectid,namewhereage>25;
 
 
注意:传统数据块的形式insert into table values(字段1,字段2),这种形式hive是不支持的。
 
分区:在Hive中,表的每一个分区对应表下的相应目录,所有分区的数据都是存储在对应的目录中。
装载数据相当于把之前HDFS上的数据移动到hive对应的目录下。

猜你喜欢

转载自windyqin.iteye.com/blog/2331773