Re: how to "pg_dump", based in select command

From: "Josh Tolley" <eggyknap(at)gmail(dot)com>
To: "Jeferson Kasper" <jefersonkasper(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: how to "pg_dump", based in select command
Date: 2007-07-03 17:52:11
Message-ID: e7e0a2570707031052ie1d2cb9oef59942e35137be7@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 7/3/07, Jeferson Kasper <jefersonkasper(at)gmail(dot)com> wrote:
> Hello folks.
> I want to know how to dump some parts of a database?
> I need to extract the records in a "select * from table" and the pg_dump or
> other tool will create a file with the records found in this "select
> command", and after this, i will restore this file in another database with
> the same structure.
> Any idea?
> Thanks people.
>
> Jeferson Kasper
>

In 8.2 you can use the COPY command with a query, as in COPY (SELECT
...) TO 'filename'

In earlier versions, one alternative is to create a table filled with
the results of your query and pg_dump it. Alternatively you might also
pipe the query into psql and pipe the output to a file, use psql's \o
option, etc.

-Josh

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Martijn van Oosterhout 2007-07-03 17:52:39 Re: Proposal: In-Place upgrade concept
Previous Message Zdenek Kotala 2007-07-03 17:13:29 Re: Proposal: In-Place upgrade concept