一、Insert导出
1.将查询结果导出到本地
insert overwrite local directory '/root/hivedata/export/student1'
select * from student1;
2.将查询的结果“格式化”导出到本地
insert overwrite local directory '/root/hivedata/export/student2'
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
select * from student2;
3.将查询的结果导出到HDFS上(没有local)
insert overwrite directory '/user/root/school'
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' (小写也可以)
select * from school;
二、Hadoop命令导出到本地
dfs -get /user/hive/warehouse/student/month=201908/000000_0
/root/hivedata/export/stu_out.txt
三、Hive Shell命令导出
基本语法:
(hive -f/-e 执行语句或者脚本 > file)
实操案例:
bin/hive -e 'select * from default.student;' > /root/hivedata/export/stu_shell.txt;
四、Export导出到HDFS上
export table default.student to '/user/hive/warehouse/hdfs';
五、Sqoop导出
后续讲解
六、清除表中数据
truncate table student;
注意:Truncate只能删除管理表,不能删除外部表中数据