dbTalk Databases Forums  

pg_dump -t: give WHERE condition

comp.databases.postgresql comp.databases.postgresql


Discuss pg_dump -t: give WHERE condition in the comp.databases.postgresql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Thomas Guettler
 
Posts: n/a

Default pg_dump -t: give WHERE condition - 12-03-2007 , 08:36 AM






Hi,

I want to dump some rows of a table. I couldn't find a way to
give pg_dump a where condition.

How can you dump (for restore) with a where-condition?

Thomas

Reply With Quote
  #2  
Old   
Laurenz Albe
 
Posts: n/a

Default Re: pg_dump -t: give WHERE condition - 12-03-2007 , 09:00 AM






Thomas Guettler <hv (AT) tbz-pariv (DOT) de> wrote:
Quote:
I want to dump some rows of a table. I couldn't find a way to
give pg_dump a where condition.

How can you dump (for restore) with a where-condition?
You cannot specify a where clause for pg_dump.

You can use COPY (or \copy in psql) to dump the results of an
arbitrary SQL query to a file.

Use COPY (or \copy) to restore the result to another table.

Yours,
Laurenz Albe


Reply With Quote
  #3  
Old   
Thomas Guettler
 
Posts: n/a

Default Re: pg_dump -t: give WHERE condition - 12-04-2007 , 10:06 AM



Thank you Toby and Laurenz for your solutions.

Toby A Inkster schrieb:
Quote:
Laurenz Albe wrote:

You can use COPY (or \copy in psql) to dump the results of an arbitrary
SQL query to a file.

Personally, I'd...

$ psql mydb
> CREATE TABLE temp1 (LIKE mytable);
> INSERT INTO temp1 SELECT * FROM mytable WHERE myconditions;
> \q
$ pg_dump --data-only --column-inserts -t temp1 mtdb >out.sql
$ psql mydb
> DROP TABLE temp1;
> \q


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.