Обсуждение: How to export query results to excel file using psql command in postgresql

Поиск
Список
Период
Сортировка

How to export query results to excel file using psql command in postgresql

От
Naveen Kumar
Дата:
How to export query results to excel file using psql command in postgresql

Re: How to export query results to excel file using psql command in postgresql

От
Pavel Stehule
Дата:
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

Re: How to export query results to excel file using psql command in postgresql

От
Paul Förster
Дата:
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


Re: How to export query results to excel file using psql command in postgresql

От
Adrian Klaver
Дата:
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