gpt4 book ai didi

linux - Windows 和 Linux 的 postgres 转储是否不同?

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:55:22 25 4
gpt4 key购买 nike

我有一个包含序列的 postgres 数据库。当我从运行 Windows 的开发机器上转储它时,它会产生以下内容

CREATE SEQUENCE "some_sequence"
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;

但是,如果我尝试在 Linux 机器上恢复它,它会抛出一个错误,指出 AS integer 行无效,但当删除该行时,它会按预期工作。 linux 机器运行的是 v9.5.11,windows 上的机器是 postgres 10。

这是否与不同的操作系统有关,还是我做错了什么?

最佳答案

https://www.postgresql.org/docs/devel/static/release-10.html

Add CREATE SEQUENCE AS command to create a sequence matching an integer data type

所以它是版本 10 中的新语法,显然 9.5 无法理解它。

还有

https://www.postgresql.org/docs/current/static/app-pgdump.html

Because pg_dump is used to transfer data to newer versions of PostgreSQL, the output of pg_dump can be expected to load into PostgreSQL server versions newer than pg_dump's version. pg_dump can also dump from PostgreSQL servers older than its own version. (Currently, servers back to version 8.0 are supported.) However, pg_dump cannot dump from PostgreSQL servers newer than its own major version; it will refuse to even try, rather than risk making an invalid dump. Also, it is not guaranteed that pg_dump's output can be loaded into a server of an older major version — not even if the dump was taken from a server of that version. Loading a dump file into an older server may require manual editing of the dump file to remove syntax not understood by the older server. Use of the --quote-all-identifiers option is recommended in cross-version cases, as it can prevent problems arising from varying reserved-word lists in different PostgreSQL versions.

因此,如果您执行相反的操作 - 转储 9.5 并将其恢复为 10,它会起作用,但反之则不行。

关于linux - Windows 和 Linux 的 postgres 转储是否不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48740183/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com