Re: pg_dump with select command

From: Ondrej Ivanič <ondrej(dot)ivanic(at)gmail(dot)com>
To: pgsql-general General <pgsql-general(at)postgresql(dot)org>
Subject: Re: pg_dump with select command
Date: 2011-09-12 05:48:27
Message-ID: CAM6mie+8hZPyaXCGgHTwS3=ECzwkLyLn99R4LEtkXgUG7+yNnA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

On 12 September 2011 15:03, Adarsh Sharma <adarsh(dot)sharma(at)orkash(dot)com> wrote:
> Today I need some part ( subset ) of some tables to another database to a
> remote server.
> I need to take backup of  tables after satisfying a select query.
>
> Is there any option to specify query in pg_dump command.I researched in the
> manual but not able to find that.
> Please let me know if it is possible as we can can specify in mysqldump
> command.

No, pg_dump can dump full tables only. You can use psql:

psql -h <host1> ... -c 'copy (select ... from <tablename> where ...)
to stdout' | psql -h <host2> ... -c 'copy <tablename> from stdin'

(where '...' are other psql's options like user, db, ...)

--
Ondrej Ivanic
(ondrej(dot)ivanic(at)gmail(dot)com)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Simon Riggs 2011-09-12 06:46:50 Re: servoy-postgresql plugin
Previous Message Adarsh Sharma 2011-09-12 05:03:02 pg_dump with select command