来自 Windows 和 Linux 的 postgres 转储是否不同?
Do postgres dumps from Windows and Linux differ?
我有一个包含序列的 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.
这是否与不同的操作系统有关,还是我做错了什么?
原来是版本冲突(我写完题才查版本)。将 linux 机器上的 postgres 更新到 10.2 解决了这个问题。
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,它会起作用,但反之则不行。
我有一个包含序列的 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.
这是否与不同的操作系统有关,还是我做错了什么?
原来是版本冲突(我写完题才查版本)。将 linux 机器上的 postgres 更新到 10.2 解决了这个问题。
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,它会起作用,但反之则不行。