导入数据到hive外部表

导入数据到hive外部表;
1.hive命令创建外部表。
create EXTERNAL table applogsnew
(
applogid string,
msgtype string,
clienttype string,
userid bigint
)
PARTITIONED BY (create_time string)
row format delimited
fields terminated by ' '
stored as textfile
location '/data/sda/apache-hive-1.2.1-bin/tmp/warehouse/applogsnew';
2.通过hadoop命令创建目录,上传文件到对应的目录。
hadoop fs -mkdir /data/sda/apache-hive-1.2.1-bin/tmp/warehouse/applogsnew/create_time=20160531
hadoop fs -put /home/appadmin/web/000000_0 /data/sda/apache-hive-1.2.1-bin/tmp/warehouse/applogsnew/create_time=20160531/

3.通过hive命令关联数据到分区
alter table applogsnew add partition (create_time='20160531') location '/data/sda/apache-hive-1.2.1-bin/tmp/warehouse/applogsnew/create_time=20160531';

原文地址:https://www.cnblogs.com/zlzhoulei/p/5569831.html