从sql文件还原单表转储 [英] restore single table dump from a sql file
本文介绍了从sql文件还原单表转储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有完整的sql文件转储,例如 dump_full.sql
,大小为 1.3GB
I have full dump of sql file like dump_full.sql
of size 1.3GB
它有一些表,例如
dancing_core_spice
dancing_sea_beast
forde_clear_one
forde_super_now
现在我要恢复/获取/转储 dump_full.sql
file
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
所以有人可以让我知道如何从sql文件中提取单个表的转储(完整转储)
So can anyone please let me know how to take the dump of only single table from the sql file(full dump)
推荐答案
对于这些类型的操作,转储文件应采用通过 pg_dump :
For these type of operations the dump file should be in the postgresql custom format created with pg_dump:
pg_dump -Fc
然后,您可以使用 pg_restore
pg_restore --table=dancing_core_spice dump_full.sql > dancing_core_spice.sql
此问题提供了处理实际情况的提示:
This question provides tips to handle your actual case:
- 从文件中提取sql代码。使用编辑器,脚本或其他任何方式
- 将转储恢复到临时数据库,然后使用pg_dump
这篇关于从sql文件还原单表转储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文