如何将二进制pgdump(压缩)转换为纯SQL文件?

问题描述:

我确实想在数据库转储中搜索某些数据,但是这些转储使用的是二进制压缩格式( PGDMP 标头)。

I do want to search for some data inside a database dump but these dumps are using the binary-compressed format (PGDMP header).

如何在不恢复它们的情况下将它们转换为SQL?

How can I convert these to SQL without restoring them?

pg_restore ,在没有数据库名称的情况下运行时,将文本转储输出到stdout;您可以使用 -f 或通过I / O重定向将其发送到其他地方。

pg_restore, when run without a database name, outputs a text dump to stdout; you can send that elsewhere with -f or with I/O redirection.

pg_restore -f mydatabase.sql mydatabase.dump