简体   繁体   中英

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:

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. You need to grant access for postgres user or all users for /tmp/ catalog.

In pgAdmin4, you can create a new server with super user privileges:

1) For instance, for pgAdmin4 for Windows, right-click on "Servers" in the "Browser" window > Click "Create" then "Server".

2) Enter a "Name" in the "General" tab > In the "Connection" tab, enter "Host name". "Username" should be a super user, for instance "postgres" with the proper "Password".

3) Click "Save".

Once you've done it, you can go to "Query Tool" and execute your piece of code. It works. for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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