restore single table dump from a sql file

让人想犯罪 __ 提交于 2019-12-13 06:27:04

问题


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)


回答1:


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


来源:https://stackoverflow.com/questions/21404141/restore-single-table-dump-from-a-sql-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!