[英]How to restore postgres 12 generated sql file into postgres 9.6 database
I am trying to restore the database.我正在尝试恢复数据库。 The database sql file is about 4.5 GB so I couldn't edit it on editor.数据库 sql 文件大约 4.5 GB,所以我无法在编辑器上编辑它。 I dump the database using following command in postgres 12;我在 postgres 12 中使用以下命令转储数据库;
pg_dump -d postgres > backup.sql
But I need the same database in postgres 9.6.但是我需要在 postgres 9.6 中使用相同的数据库。 For this purpose, I write the following code to restore it为此,我编写了以下代码来恢复它
psql -d postgres < backup.sql
It shows the error like this (Error in creating sequence) .它显示了这样的错误(创建序列时出错) 。 But this is not the duplicated one with given question.但这不是给定问题的重复问题。 error message;错误信息;
SET
ERROR: unrecognized configuration parameter "default_table_access_method"
CREATE TABLE
ALTER TABLE
ERROR: syntax error at or near "AS"
LINE 2: AS integer
^
ERROR: relation "epicenter.epicenter_gid_seq" does not exist
ERROR: relation "epicenter.epicenter_gid_seq" does not exist
CREATE TABLE
ALTER TABLE
ERROR: syntax error at or near "AS"
LINE 2: AS integer
^
ERROR: relation "public.725_4.5_tur_gid_seq" does not exist
ERROR: relation "public.725_4.5_tur_gid_seq" does not exist
CREATE TABLE
ALTER TABLE
I saw the answer of this question.我看到了这个问题的答案。 The answer already said the sql file will not work on older version.答案已经说过 sql 文件不适用于旧版本。 But I want to know, Is there any way to restore using this sql file?但是我想知道,有没有办法使用这个sql文件进行恢复?
Thank you @jjanes and @JGH for your kind cooperation.感谢@jjanes 和@JGH 的友好合作。 I found the one solution.我找到了一个解决方案。 First I backup the database using following command;首先我使用以下命令备份数据库;
pg_dump -U postgres -h localhost -p 5432 -W earthquake | gzip -c > backup.gz
Then I create earthquake database manually from the pgadmin 4
.然后我从pgadmin 4
手动创建地震数据库。 After getting the backup.gz
file, I restore it using following command in terminal;获取backup.gz
文件后,我在终端中使用以下命令恢复它;
gzip -d -c backup.gz | sed -e '/AS integer/d' | psql -U postgres -h localhost -p 5432 -W earthquake
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.