文章中对hive表中的数据导出 多种方法目录
[方式二:hive shell 命令导出](#方式二:hive shell 命令导出)
目标:
将hive表中的数据导出到其他任意目录,例如linux本地磁盘,例如hdfs,例如mysql等等
方式一:insert导出
1)将查询的结果导出到本地
|--------------------------------------------------------------------------------------------------------------------|
| insert overwrite local directory '/export/data/hive_data/exporthive' select * from score**;** |
2)将查询的结果格式化导出到本地
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| insert overwrite local directory '/export/data/hive_data/exporthive' row format delimited fields terminated by '\t' collection items terminated by '#' select * from student**;** |
3)将查询的结果导出到HDFS上(没有local)
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| insert overwrite directory '/export/data/hive_data/exporthive' row format delimited fields terminated by '\t' select * from score**;** |
方式二:hive shell 命令导出
基本语法:(hive -f/-e 执行语句或者脚本 > file)
|-----------------------------------------------------------------------------------------------------------------------------|
| bin / hive - e "select * from myhive.score;" > /export/data/hive_data/exporthive / score**.** txt |
方式三:export导出到HDFS上
|---------------------------------------------------------------|
| export table score to '/export/exporthive/score'; |