1、若数据文件格式恰好是用户需要的格式,只需简单的使用hdfs 命令copy即可
hadoop fs - cp source_path target_path
2 、使用 INSERT .... DIRECTORY.... ,如下面例子所示:
INSERT OVERWRITE LOCAL DIRECTORY '/home/hadoop/stu'
SELECT ID,NAME,AGE FROM T2;
下面我们将导出的数据按行以逗号进行分隔.
insert overwrite local directory '/home/hadoop/stu'
row format delimited fields terminated by ','
select * from t2;
hive> insert overwrite local directory '/home/hadoop/stu'
> row format delimited fields terminated by ','
> select * from t2;
WARNING: Hive-on-MR is deprecated in Hive 2 and may not be available in the future
versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X
releases.
Query ID = hadoop_20180830160049_43013e20-882f-4d75-9327-2611e9789bfe
查看导出的结果: