我需要给当前用户("userA")什么样的grant选项/技巧,以允许他更改另一个用户("userC")所属对象的所有者?

更准确地说,contact表归userC所有,当我执行以下查询将所有者更改为userB时,与userA连接:

alter table contact owner to userB;

我得到了这个错误:

ERROR:  must be owner of relation contact

userA拥有正常情况下所需的所有权利(create on schema赠款选项应该足够):

grant select,insert,update,delete on all tables in schema public to userA; 
grant select,usage,update on all sequences in schema public to userA;
grant execute on all functions in schema public to userA;
grant references, trigger on all tables in schema public to userA;
grant create on schema public to userA;
grant usage on schema public to userA;

Thks


命令行输出:

root@server:~# psql -U userA myDatabase
myDataBase=>\dt contact
    List of relations
Schema |  Name   |   Type   |  Owner
-------+---------+----------+---------
public | contact | table    | userC
(1 row)
myDataBase=>
myDataBase=>alter table contact owner to userB;
ERROR:  must be owner of relation public.contact
myDataBase=>

推荐答案

多亏了Mike的 comments ,我重新阅读了文档,我意识到我当前的用户(即已经拥有create特权的userA)不是direct/indirect member of the new owning role...

所以解决方案很简单——我刚刚完成了这个拨款:

grant userB to userA;

这就是所有人;-)


Update:

另一个要求是,在更改对象之前,该对象必须由用户userA拥有...

Postgresql相关问答推荐

org.postgresql. util.PSQLException:使用docker + docker—compose + kafka + springboot时try 连接失败

在Go中,如何在没有数据库包的情况下运行PostgreSQL查询?

为什么Postgres在打印时能完全缩短时间跨度?

多克.波斯格雷斯.PgAdmin4

有没有一种方法可以在参数中添加密码,并在批处理文件中需要时自动获取密码?

PostgreSql maintenance_work_mem 在索引创建期间增加

查找列中的数据是否满足sql中的数据类型条件

JPA findBy 字段忽略大小写

如何在 postgresql 上使用 sqlalchemy 进行正确的 upsert?

新数据未保存到 Postgres 上的 Rails 数组列

函数将多列作为单列而不是多列返回

在 PostgreSQL 中返回插入的行

PostgreSQL 如何比 SQLite 更快地执行写入?

保存 geodjango PointField 时出错

为什么 SQLAlchemy 不创建串行列?

Postgres 中的相似函数与 pg_trgm

在 MAC OS X 10.6 for PostgreSQL 上设置 SHMMAX 等值

如何为 Postgres psql 设置时区?

ruby on rails jsonb 列默认值

错误:permission denied for language c