我想更改我使用的序列的名称.我try 了这两种 Select ,但都失败了:

ALTER TABLE PLAYER RENAME id_seq_player TO player_id_seq;

ALTER SEQUENCE id_seq_player RENAME TO player_id_seq;

I looked at the official documentation 和 from there I created those two SQL, but none of them worked. The first solution resulted in a SQL error 和 the second had a time out.

下面是我得到的SQL错误:

ERROR:  column "id_seq_player" does not exist

********** Error **********

* UPDATE *

Seems like the second SQL statement did the job. Since I have to forward the port, maybe it was an issue with the connection or OpenShift. But now I retried several times to verify 和 it works.

ALTER SEQUENCE id_seq_player RENAME TO player_id_seq; /* Works */

推荐答案

ALTER SEQUENCE id_seq_player RENAME TO player_id_seq;

这是正确的.您可能还想添加模式名称,以确保更改的是正确的名称,但这很可能会起作用.

如果超时,可能还有另一个进程正在锁定序列.是否有办法关闭所有其他数据库用户,或者这样做是否太关键?

Postgresql相关问答推荐

在Docker容器内的Postgres,如何通过Promail将JSON登录到Loki?

Postgres SQL:获取列值在连续日期之间已更改的行

时间戳的postgreSQL-to_char如果为零,则不显示微秒

如何诊断字符编码问题

在 Windows 上使用 rsync 进行 Postgresql 副本升级

包含间隔在 jooq 和 postgres 中没有按预期工作

postgres 中的模式前缀,被调用元素的范围

如何在 PostgreSQL hstore 中使用通配符查询值

如何在 Postgres 中的列上删除唯一约束?

INSERT RETURNING 是否保证以 right的顺序返回?

升级到 OSX Mavericks 后修复 postgresql

在远程机器上Restore dump

datagrip 无法应用更改 此表是只读的

将 csv 文件中存在的 NULL 值复制到 postgres

带有偏移限制的 Select 查询太慢了

Entity Framework Core jsonb 列类型

Oracle 相当于 Postgres 的 DISTINCT ON?

避免通过 JPA 将null值插入数据库表

PostgreSQL 多种认证方式

postgresql 删除级联