PostgreSQL - restoring one table from database dump -


how can restore 1 table database dump ? make dump using next command:

pg_dump -u admin -h localhost my-db-name | gzip - > /home/a2_db_backup/my-db-name-backup.sql.gz 

there no easy way, except hacks (like using awk cut part of file).

if dump not big, easiest thing restore full backup temporary database (gzcat backup_file.gz | psql -h host -u user database_name) dump 1 table (pg_dump -t my_table), restore it.

for future custom format (pg_dump -fc > database.dump) way go. can use pg_restore restore single table : pg_restore -t my_table -d database_name database.dump .


Comments