我想将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文件
发布评论