小编ogi*_*inc的帖子

如何在不丢失数据的情况下将 PostgreSQL 从 9.5 升级到 9.6.1?

当我试图跑步时psql,我得到了

psql: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
Run Code Online (Sandbox Code Playgroud)

当我检查时Server.log,我看到:

FATAL: database files are incompatible with server
DETAIL: The data directory was initialized by PostgreSQL version 9.5,
        which is not compatible with this version 9.6.1.
Run Code Online (Sandbox Code Playgroud)

我尝试按照本教程(从 9.4 到 9.5)升级 9.6.1,但不断收到此错误消息

cannot write to log file pg_upgrade_internal.log
Failure, exiting
Run Code Online (Sandbox Code Playgroud)

跑完后

$ pg_upgrade -v \
> -d /usr/local/var/postgres \
> …
Run Code Online (Sandbox Code Playgroud)

postgresql postgresql-9.5 postgresql-9.6

6
推荐指数
1
解决办法
9840
查看次数

添加新列时使用不为空的默认值是否安全?

我们有一个由 Postgresql v11.4提供支持的 Rails 应用程序,我想在其中添加一个具有默认值和非空约束的新列,如下所示:

ALTER TABLE "blogs" ADD "published" boolean DEFAULT FALSE NOT NULL
Run Code Online (Sandbox Code Playgroud)

我知道添加具有默认值的新列是安全的。但是,与 组合使用仍然安全吗NOT NULL?或者它会锁定数据库吗?谢谢!

postgresql null default-value alter-table postgresql-11

6
推荐指数
1
解决办法
1万
查看次数