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 <naveenmcp@gmail.com>
Дата:
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 <pavel.stehule@gmail.com>
Дата:
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 <paul.foerster@gmail.com>
Дата:
Hi Naveen,

> On 13. Aug, 2020, at 16:10, Naveen Kumar  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 <adrian.klaver@aklaver.com>
Дата:
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


FAQ