Re: How to data dump a table content to a CSV or XML format?

From: Ben Madin <lists(at)remoteinformation(dot)com(dot)au>
To: pgsql-general(at)postgresql(dot)org
Cc: "Wang, Mary Y" <mary(dot)y(dot)wang(at)boeing(dot)com>
Subject: Re: How to data dump a table content to a CSV or XML format?
Date: 2010-10-04 23:35:28
Message-ID: A2A686D9-4184-433B-AF8D-AE8729C77108@remoteinformation.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Or in psql you can look at the help (\?) and set the output format to unaligned, comma separated, and output the table to disk :

database=> \pset fieldsep ,
Field separator is ",".
database=> \a
Output format is unaligned.
database=> \o table.csv
database=> SELECT * FROM table;
database=> \o

cheers

Ben

On 05/10/2010, at 6:59 AM, Wang, Mary Y wrote:

> Hi All,
>
> I'd like to do a data dump of a table to a CSV or XML file.
> How would I do that?
>
> I'm running on Postgres 8.3.8.
>
> Thanks in advance.
> Mary Wang
>
>
>
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2010-10-05 00:51:43 Re: [Off Topic] Software load balancing question
Previous Message Ben Madin 2010-10-04 23:31:06 Re: Having two simultaneous and similar database