If you are starting with a live database, you can simply use pg_dump to backup only one table:
pg_dump --data-only --table=tablename sourcedb > onetable.pg
which you can then restore in the other database:
psql destdb < onetable.pg
But even if all you've got is a full dump of the source database, you can still restore that single table by simply extracting it out of the large dump first:
pg_restore --data-only --table=tablename fulldump.pg > onetable.pg
before restoring it as shown above, using psql.



2 comments:
Generally, it's better to do your dumping via
pg_dump -Fc
which lets you then use the full power of pg_restore.
do you know of any issues if you are restoring the partition of a table and the parent table structure has changed after partition was backed up? will postgres handle this case correctly?
Post a Comment