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
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
> 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
--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 9 days, 27 min.]
Sharing Music with Apple iTunes
http://tobyinkster.co.uk/blog/2007/11/28/itunes-sharing/
Toby A Inkster schrieb: