Re: pg_dump with select output - Mailing list pgsql-general

From Sim Zacks
Subject Re: pg_dump with select output
Date
Msg-id 4D5BD08B.90206@compulab.co.il
Whole thread Raw
In response to pg_dump with select output  (Adarsh Sharma <adarsh.sharma@orkash.com>)
List pgsql-general
On 02/16/2011 11:54 AM, Adarsh Sharma wrote:

>  Dear all,
>
> I am using pg_dump in Postgresql database very often and read several
> parameters of it.
> But today i want to back up that part of table which satisfies
> satisfies certain condition ( select command ).
>
> In mysql , this is achieved as below :
>
> mysqldump -h192.168.1.106 -uroot -porkash -q -w"internalurl_id between
> 1 and 30" bicrawler internalurl > /root/Desktop/internal_url.sql
>
> -w option is used for executing select command .
>
> But don't know how this is achieved through pg_dump command.
>
Not through pgdump, but you can do it with psql like such
psql -h 192.168.1.106 -d bicrawler -o /root/Desktop/internal_url.sql -P
format=unaligned -P fieldsep="|,|" -t -U postgres -c "select * from
internalurl where internalurl_id between 1 and 30 "

Note that you have to have postgres (or the user you are using)
authenticated by trust or it will ask for a password. You can't put the
password on the command line, though you can use a .pgpass file.


> Please help.
>
>
> Thanks & best Regards,
>
> Adarsh Sharma
>


pgsql-general by date:

Previous
From: Raymond O'Donnell
Date:
Subject: Re: pg_dump with select output
Next
From: Aljoša Mohorović
Date:
Subject: server setup/testing performance