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