Re: Exporting postgres query to CSV
От | John Purser |
---|---|
Тема | Re: Exporting postgres query to CSV |
Дата | |
Msg-id | 20060509085757.cbd95387.jmpurser@gmail.com обсуждение исходный текст |
Ответ на | Exporting postgres query to CSV (Ryan Suarez <ryan.suarez@sheridanc.on.ca>) |
Ответы |
Re: Exporting postgres query to CSV
|
Список | pgsql-general |
On Tue, 09 May 2006 10:58:07 -0400 Ryan Suarez <ryan.suarez@sheridanc.on.ca> wrote: > Greetings, > > I am running postgres 7.4.7 on debian sarge. > > I need to run an SQL query and store the results in a file. The > format needs to be comma separated values (CSV), so I can import this > later in Excel. > > Any ideas on how to accomplish this? > > much appreciated, > Ryan > > > ---------------------------(end of > broadcast)--------------------------- TIP 6: explain analyze is your > friend Ryan, Two tips. First: psql -U <PGSQL USER> -o <OUPUT FILE NAME> --pset format=unaligned --pset fieldsep=',' -c '<SQL COMMAND HERE>' -d <DATABASE NAME HERE> I think that will give you the output you were after assuming you're scripting psql and that you replace the values in <> with appropriate values. The syntax is slightly different from the psql command line. Second: man psql is your friend. John Purser
В списке pgsql-general по дате отправления: