简体   繁体   English

将查询结果从 pgadmin 导出到 excel 文件

[英]Export query result from pgadmin to excel file

I am trying to export the result from a query in pgadmin to a excel file i have tried:我正在尝试将 pgadmin 中的查询结果导出到我尝试过的 excel 文件中:

COPY (Select * From SYSTEMS) To '/tmp/test.csv' With CSV;

but it returns the error:但它返回错误:

ERROR: must be superuser to COPY to or from a file

pgadmin, running under "pgadmin system user" can't accese to /tmp/ catalog.在“pgadmin 系统用户”下运行的 pgadmin 无法访问 /tmp/ 目录。 You need to grant access for postgres user or all users for /tmp/ catalog.您需要为 postgres 用户或所有用户授予 /tmp/ 目录的访问权限。

In pgAdmin4, you can create a new server with super user privileges:在 pgAdmin4 中,您可以创建一个具有超级用户权限的新服务器:

1) For instance, for pgAdmin4 for Windows, right-click on "Servers" in the "Browser" window > Click "Create" then "Server". 1) 例如,对于 Windows 的 pgAdmin4,右键单击“浏览器”窗口中的“服务器”> 单击“创建”,然后单击“服务器”。

2) Enter a "Name" in the "General" tab > In the "Connection" tab, enter "Host name". 2) 在“常规”选项卡中输入“名称” > 在“连接”选项卡中,输入“主机名”。 "Username" should be a super user, for instance "postgres" with the proper "Password". “用户名”应该是超级用户,例如具有正确“密码”的“postgres”。

3) Click "Save". 3) 点击“保存”。

Once you've done it, you can go to "Query Tool" and execute your piece of code.完成后,您可以转到“查询工具”并执行您的代码段。 It works.它有效。 for me.对我来说。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM