繁体   English   中英

从 sql 文件恢复单表转储

[英]restore single table dump from a sql file

我有 sql 文件的完整转储,例如大小为1.3GBdump_full.sql

它有一些表格,例如

dancing_core_spice
dancing_sea_beast

forde_clear_one
forde_super_now

现在我想要的是只需要从dump_full.sql文件中恢复/获取/转储这些表的only data

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

我尝试了上面的命令,但它不起作用

所以任何人都可以让我知道如何从 sql 文件中只转储单个表(完整转储)

对于这些类型的操作,转储文件应该是使用pg_dump创建的 postgresql 自定义格式:

pg_dump -Fc

然后您可以使用pg_restore恢复单个表

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

这个问题提供了处理您的实际案例的提示:

  • 从文件中提取 sql 代码。 使用编辑器、脚本或其他任何东西
  • 将转储恢复到临时数据库并使用 pg_dump 再次转储

暂无
暂无

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

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