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

编程入门 行业动态 更新时间:2024-10-28 04:20:46
本文介绍了查看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?

UPDATE :这些是非文本文件。它们是二进制。它们来自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备份使用本机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 ...).

另一种可能的方法(可能不起作用,没有尝试过)是 grep 通过 pg_restore your_db_dump.file 命令的输出。如果我正确理解了手册- 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:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1523353.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:简单   方法   postgresql   储文

发布评论

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

>www.elefans.com

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