![](/img/trans.png)
[英]Import CSV file from URL into SQL Fiddle Postgres 9.6 engine
[英]How to restore postgres 12 generated sql file into postgres 9.6 database
我正在尝试恢复数据库。 数据库 sql 文件大约 4.5 GB,所以我无法在编辑器上编辑它。 我在 postgres 12 中使用以下命令转储数据库;
pg_dump -d postgres > backup.sql
但是我需要在 postgres 9.6 中使用相同的数据库。 为此,我编写了以下代码来恢复它
psql -d postgres < backup.sql
它显示了这样的错误(创建序列时出错) 。 但这不是给定问题的重复问题。 错误信息;
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
我看到了这个问题的答案。 答案已经说过 sql 文件不适用于旧版本。 但是我想知道,有没有办法使用这个sql文件进行恢复?
感谢@jjanes 和@JGH 的友好合作。 我找到了一个解决方案。 首先我使用以下命令备份数据库;
pg_dump -U postgres -h localhost -p 5432 -W earthquake | gzip -c > backup.gz
然后我从pgadmin 4
手动创建地震数据库。 获取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.