查看 postgresql 转储文件的简单方法? [英] Easy way to view postgresql dump files?

查看:57
本文介绍了查看 postgresql 转储文件的简单方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有大量的 postgresql 转储文件,我需要仔细阅读数据.我是否必须安装 Postgresql 并将它们中的每一个恢复"到新数据库中?或者我希望有一个 postgresql 客户端可以简单地打开它们,我可以查看数据,甚至可以运行一个简单的 SQL 查询?

I have a ton of postgresql dump files I need to peruse through for data. Do I have to install Postgresql and "recover" each one of them into new databases one by one? Or I'm hoping there's a postgresql client that can simply open them up and I can peek at the data, maybe even run a simple SQL query?

转储文件均来自 Postgresql v9.1.9 服务器.

The dump files are all from a Postgresql v9.1.9 server.

或者也许有一种工具可以轻松地将数据库连接"到转储文件?

Or maybe there's a tool that can easily make a database "connection" to the dump files?

更新:这些不是文本文件.它们是二进制.它们来自 Heroku 的备份机制,这是 Heroku 关于他们如何创建备份的说明:

UPDATE: These are not text files. They are binary. They come from Heroku's backup mechanism, this is what Heroku says about how they create their backups:

PG Backups 使用原生的 pg_dump PostgreSQL 工具来创建它的备份文件,使得导出到其他 PostgreSQL 变得微不足道安装.

PG Backups uses the native pg_dump PostgreSQL tool to create its backup files, making it trivial to export to other PostgreSQL installations.

推荐答案

尝试使用文本编辑器打开文件 - 默认转储格式为纯文本.

Try opening the files with text editor - the default dump format is plain text.

如果转储不是纯文本 - 尝试使用 pg_restore -l your_db_dump.file 命令.它将列出数据库转储中的所有对象(如表、索引...).

If the dump is not plain text - try using pg_restore -l your_db_dump.file command. It will list all objects in the database dump (like tables, indexes ...).

另一种可能的方法(可能行不通,没试过)是通过pg_restore your_db_dump.file 命令的输出grep.如果我正确理解手册 - pg_restore 的输出只是一系列 SQL 查询,这将重建数据库.

Another possible way (may not work, haven't tried it) is to grep through the output of pg_restore your_db_dump.file command. If I understood correctly the manual - the output of pg_restore is just a sequence of SQL queries, that will rebuild the db.

这篇关于查看 postgresql 转储文件的简单方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆