hive查询结果如何以csv的格式存储到本地磁盘

方式一

INSERT OVERWRITE LOCAL DIRECTORY '/tmp/data.csv' select books from table;
或者存储到hdfs
INSERT OVERWRITE DIRECTORY '/user/data.csv' select books from table;

方式二

hive -e 'select books from table' | sed 's/[[:space:]]\+/,/g' > /tmp/data.csv
或者
hive -e 'select books from table' | sed 's/[\t]\+/,/g' > /tmp/data.csv
posted @ 2020-06-29 11:38  北漂-boy  阅读(1047)  评论(0编辑  收藏  举报