| From: | Brent Wood <b(dot)wood(at)niwa(dot)co(dot)nz> |
|---|---|
| To: | Francisco Reyes <lists(at)stringsutils(dot)com> |
| Cc: | PostgreSQL general <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: Command line export or copy utility? |
| Date: | 2007-05-22 23:29:05 |
| Message-ID: | 46537CC1.9030904@niwa.co.nz |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Francisco Reyes wrote:
> Does anyone know of any export or copy utility that runs on FreeBSD?
> I basically need a program that will connect to one database, do a
> select and copy the result to a second database.
There are a few ways, from memory (so I might have the odd syntax error):
To replicate a table run pg_dump on one machine pointing at the host/db
to export & pipe the output to psql -f with the host & name of the
target db.
pg_dump -h host0 -d db0 -t table ... | psql -h host1 -d db1 -f
you can do similar data streams from one db to another with (if the
target table exists):
psql .... -c "copy table to STDOUT ..." | psql ... -c "copy table from
STDOUT ..."
to do this with the results of a query to subset the data will require
the pre-building of the target table, but you can do:
psql -h host0 -d db0 -F"|" -Atc "select.....;" | psql -h host1 -d db1 -c
"copy table from STDIN with delimiters = '|';"
Cheers,
Brent Wood
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Reece Hart | 2007-05-22 23:31:36 | Re: Command line export or copy utility? |
| Previous Message | Scott Ribe | 2007-05-22 23:02:07 | Re: Command line export or copy utility? |