postgresql - 恢复多个表 postgresql pg_dump

标签 postgresql

我有一个包含多个表的数据库,我想将其中一部分的数据和结构添加到包含不同表的不同数据库中。

我按以下方式创建了转储文件:

"C:\Program Files\PostgreSQL\9.1\bin\pg_dump.exe" -U postgres -w DBName -t table1 -t Table2 -t Table3 > "E:\Dump.sql"

这工作正常,我有 E:\Dump.sql,其中包含三个表的转储。 我尝试使用以下代码进行恢复:

"C:\Program Files\PostgreSQL\9.6\bin\pg_dump.exe" -C -U User -t table1 -t Table2 -t Table4 destdb < Dump.sql

但是我得到了错误

no matching tables were found

.

我哪里做错了?

最佳答案

https://www.postgresql.org/docs/current/static/backup-dump.html

pg_dump用于**进行*备份,手册的下一部分用于恢复备份:

Text files created by pg_dump are intended to be read in by the psql program. The general command form to restore a dump is

psql dbname < infile

你还提到了三个表,其中两个是大小写混合的 - 为了让它工作,我相信你必须双引号。但无论如何 - 为您恢复文件将是:

psql YOURDBNAME -f E:\Dump.sql

关于postgresql - 恢复多个表 postgresql pg_dump,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48529238/

相关文章:

java - 与 python psycopg2 相比,使用 clojure jdbc 将文件记录插入 postgres db 需要很长时间

python - 将 Django 连接到 Postgres : django. db.utils.OperationalError: FATAL: database "DATABASENAME"does not exist

django - 如何将 PyCharm 连接到 Heroku postgres 数据库

更新/插入触发器之前的 Postgresql 似乎不起作用

PostgreSQL:如何在不指定参数的情况下 DROP FUNCTION IF EXISTS?

sql - 使用 postgresql 随机排序时的确定性顺序

PostgreSQL 从子查询更新

Python SQLAlchemy 和 Postgres - 如何使用 json 值中的子字符串进行搜索

database - 如何连接到不使用 pgadmin3.. 密码的 postgres 数据库?

sql - 如何创建一个已经安装了 hstore 扩展的新数据库?