查看 postgresql 转储文件的简单方法?

编程入门 行业动态 更新时间:2024-10-28 02:33:01
本文介绍了查看 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 转储文件的简单方法?

本文发布于:2023-10-24 07:48:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1523352.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:简单   方法   postgresql   储文

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!