我有一个包含多个表的数据库,我想将其中一部分的数据和结构添加到包含不同表的不同数据库中。
我按以下方式创建了转储文件:
"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/