Forum OpenACS Q&A: copy table from one db to another

Collapse
Posted by David Kuczek on
Has anyone ever copied one table and its content (without constraints)
from one db to another on the same machine?

What command do I have to use for that?

Collapse
Posted by Steve Woodcock on

You can do it with pg_dump:

  pg_dump -t the_table db1 | psql db2
Collapse
Posted by David Kuczek on
Thanks a lot... It worked
Collapse
Posted by Jeff Barrett on
Can this be done for a remote machine? If I wanted to dump a table on dbmachine1 and have it loaded into dbmachine2 is their a way I can do that?
Collapse
Posted by Steve Woodcock on
Have a look at man psql, the -h and -U options, for something like this:
[dbmachine1]$ pg_dump -t the_table db1 | psql -h dbmachine2 db2
(Note I've never actually done this myself...)