PostgreSQL查询输出为Excel文件

编程入门 行业动态 更新时间:2024-10-28 14:26:07
本文介绍了PostgreSQL查询输出为Excel文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想将psql查询的结果另存为Excel文件.即,我有一个名为5列的公司表.我要执行查询,

I want to save the result of a psql query as an Excel file. ie, I have a table named company with 5 column. I want to execute the query,

SELECT column_1, column_2, FROM company;

我只想将此查询的结果另存为Excel文件.在PostgreSQL中可以吗?如果是的话,请解释一下.

And I just want to save the result of this query as a Excel file. Is it possible in PostgreSQL? If yes then please explain it.

谢谢...

推荐答案

您可以使用csv保存数据并在Excel中打开/使用它们.语法类似于:

You could use csv to save your data and open/work with them in Excel. Syntax would be something like:

Copy (SELECT column_1, column_2, FROM company; ) To '/tmp/test.csv' With CSV;

此查询将在服务器上运行.您还可以使用客户端上运行的 \ query 并在本地保存数据.另请参见另一个 SE问题

This query would run on server. You could also make usage of \query which is running on your client and saving the data locally. See also another SE question

更多推荐

PostgreSQL查询输出为Excel文件

本文发布于:2023-10-23 06:27:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1520058.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   PostgreSQL   Excel

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!