[英]Postgresql: Cannot restore schema from pg_dump
I am trying to move a schema from one database to another using pg_dump
. 我正在尝试使用
pg_dump
将模式从一个数据库移动到另一个数据库。 I am running this command to take a backup of my schema 我正在运行此命令来备份我的架构
pg_dump.exe -h myhost -U postgres -d mydb-n schema> C:\Temp\schema.dump
To restore it I copy the SQL
into pgadmin
, but I get this error. 要还原它,我将
SQL
复制到pgadmin
,但是出现此错误。 I don't know what the issue is ? 我不知道问题是什么?
ERROR: syntax error at or near "2"
LINE 284: 2 \N Unregistered. Item \N 2016-07-13 00:00:00 \N
Is there a best recommended way to backup/restore a postgres
database? 有没有推荐的最佳方法来备份/还原
postgres
数据库? I often run into issues similar issues when backing up/restoring databases and I start to worry that I will loose valuable data one day. 在备份/还原数据库时,我经常遇到类似的问题,并且我开始担心自己一天会丢失有价值的数据。
A plain text pg_dump
cannot be restored with pgAdmin since pgAdmin cannot perform COPY FROM STDIN
, which is used by pg_dump
for the data by default. 由于pgAdmin无法执行
COPY FROM STDIN
,因此无法使用pgAdmin恢复纯文本pg_dump
,默认情况下pg_dump
使用COPY FROM STDIN
。
You'll have to use psql
to restore the dump. 您必须使用
psql
还原转储。
An alternative would be to use the --inserts
option of pg_dump
so that the data are dumped as INSERT
statrments. 一种替代方法是使用
pg_dump
的--inserts
选项,以便将数据作为INSERT
声明转储。 This comes with a performance penalty though. 但是,这会带来性能损失。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.