Thread: pg_dump with select output

pg_dump with select output

From
Adarsh Sharma
Date:
  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.

Please help.


Thanks & best Regards,

Adarsh Sharma

Re: pg_dump with select output

From
Raymond O'Donnell
Date:
On 16/02/2011 09:54, 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.

You can't do this in pg_dump. pg_dump can backup:

- the entire database
- a schema, using -s
- a table, using -t

...but not a subset of rows from a table. Maybe you want the COPY command?

   http://www.postgresql.org/docs/9.0/static/sql-copy.html

Ray.

--
Raymond O'Donnell :: Galway :: Ireland
rod@iol.ie

Re: pg_dump with select output

From
Sim Zacks
Date:
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
>