简体   繁体   English

从 sql 文件恢复单表转储

[英]restore single table dump from a sql file

I have full dump of sql file like dump_full.sql of size 1.3GB我有 sql 文件的完整转储,例如大小为1.3GBdump_full.sql

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现在我想要的是只需要从dump_full.sql文件中恢复/获取/转储这些表的only data

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)所以任何人都可以让我知道如何从 sql 文件中只转储单个表(完整转储)

For these type of operations the dump file should be in the postgresql custom format created with pg_dump :对于这些类型的操作,转储文件应该是使用pg_dump创建的 postgresql 自定义格式:

pg_dump -Fc

Then you can restore a single table with pg_restore然后您可以使用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.从文件中提取 sql 代码。 With an editor, a script or whatever使用编辑器、脚本或其他任何东西
  • Restore the dump to temp database and dump it again with pg_dump将转储恢复到临时数据库并使用 pg_dump 再次转储

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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