简体   繁体   中英

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.sql file

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)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM