pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedHow to export query results to excel file using psql command in postgresql
4+ messages / 4 participants
[nested] [flat]
* How to export query results to excel file using psql command in postgresql
@ 2020-08-13 14:10 Naveen Kumar <naveenmcp@gmail.com>
0 siblings, 3 replies; 4+ messages in thread
From: Naveen Kumar @ 2020-08-13 14:10 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
How to export query results to excel file using psql command in postgresql
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: How to export query results to excel file using psql command in postgresql
@ 2020-08-13 14:15 Pavel Stehule <pavel.stehule@gmail.com>
parent: Naveen Kumar <naveenmcp@gmail.com>
2 siblings, 0 replies; 4+ messages in thread
From: Pavel Stehule @ 2020-08-13 14:15 UTC (permalink / raw)
To: Naveen Kumar <naveenmcp@gmail.com>; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Hi
čt 13. 8. 2020 v 16:10 odesílatel Naveen Kumar <naveenmcp@gmail.com> napsal:
> How to export query results to excel file using psql command in postgresql
>
Excel can import csv file
so you can
for Postgres 12
\pset format csv
\o path_to_file
select * from ...
or for older postgres
\copy (select * from ...) to path_to_file CSV HEADER
Regards
Pavel
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: How to export query results to excel file using psql command in postgresql
@ 2020-08-13 14:15 Paul Förster <paul.foerster@gmail.com>
parent: Naveen Kumar <naveenmcp@gmail.com>
2 siblings, 0 replies; 4+ messages in thread
From: Paul Förster @ 2020-08-13 14:15 UTC (permalink / raw)
To: Naveen Kumar <naveenmcp@gmail.com>; +Cc: PostgreSQL General <pgsql-general@lists.postgresql.org>
Hi Naveen,
> On 13. Aug, 2020, at 16:10, Naveen Kumar <naveenmcp@gmail.com> wrote:
>
> How to export query results to excel file using psql command in postgresql
use the "copy" command along with its CSV output setting. Then open the CSV file with Excel.
Look here:
https://www.postgresqltutorial.com/export-postgresql-table-to-csv-file/
https://www.postgresql.org/docs/current/sql-copy.html
Cheers,
Paul
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: How to export query results to excel file using psql command in postgresql
@ 2020-08-13 14:15 Adrian Klaver <adrian.klaver@aklaver.com>
parent: Naveen Kumar <naveenmcp@gmail.com>
2 siblings, 0 replies; 4+ messages in thread
From: Adrian Klaver @ 2020-08-13 14:15 UTC (permalink / raw)
To: Naveen Kumar <naveenmcp@gmail.com>; pgsql-general@lists.postgresql.org
On 8/13/20 7:10 AM, Naveen Kumar wrote:
> How to export query results to excel file using psql command in postgresql
You can't. You can export to CSV that you could then import into Excel.
See:
https://www.postgresql.org/docs/12/app-psql.html
\copy
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2020-08-13 14:15 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-08-13 14:10 How to export query results to excel file using psql command in postgresql Naveen Kumar <naveenmcp@gmail.com>
2020-08-13 14:15 ` Pavel Stehule <pavel.stehule@gmail.com>
2020-08-13 14:15 ` Paul Förster <paul.foerster@gmail.com>
2020-08-13 14:15 ` Adrian Klaver <adrian.klaver@aklaver.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox