Shiva Krishna Bavandla
Shiva Krishna Bavandla

Reputation: 26748

restore single table dump from a sql file

I have full dump of sql file like dump_full.sql of size 1.3GB

And it has some tables like

dancing_core_spice
dancing_sea_beast

forde_clear_one
forde_super_now

Now what i want is need to restore/fetch/dump only data of these tables from dump_full.sqlfile

psql -U postgres --table=dancing_core_spice dump_full.sql > dancing_core_spice.sql

i tried the above command but it is not working

So can anyone please let me know how to take the dump of only single table from the sql file(full dump)

Upvotes: 2

Views: 13182

Answers (1)

Francisco Puga
Francisco Puga

Reputation: 25178

For these type of operations the dump file should be in the postgresql custom format created with pg_dump:

pg_dump -Fc

Then you can restore a single table with pg_restore

pg_restore --table=dancing_core_spice dump_full.sql > dancing_core_spice.sql

This question provides tips to handle your actual case:

  • Extract the sql code from the file. With an editor, a script or whatever
  • Restore the dump to temp database and dump it again with pg_dump

Upvotes: 2

Related Questions