Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a database (it's Postgres, if that matters) and I would like to take two of its tables, export them, and then import them into another database. How do I do that?

Edited to add Google bait: dump load

share|improve this question
up vote 9 down vote accepted

Use pg_dump with the -t option (which you can specify multiple times):

pg_dump -t foo -t foo1 dbname1 > dump.sql

Restore in the new database:

psql -U username dbname2 < dump.sql
share|improve this answer

If the other database is not managed by Postgresql use pg_dump, as in Gary's hint, but with the -D flag, it makes the import process much more robust. You will have to create the schemas on the target system

(sorry, can't add a comment to Gary's answer as I don't have enough points)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.