什么是我需要给当前用户(“userA”)的grant
选项/技巧,以允许他更改属于另一个用户(“userC”)的对象所有者?
更确切地说,联系表由userC拥有,当我执行以下查询以将所有者更改为userB时,与userA连接:
alter table contact owner to userB;
我收到此错误:
ERROR: must be owner of relation contact
但是userA通常都需要权限(“在模式上创建”授权选项应该足够了):
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的评论,我重新阅读了文档,我意识到我当前的用户(即已经拥有创建权限的userA)不是新拥有角色的直接/间接成员......
所以解决方案很简单 - 我刚刚完成了这笔补助金:
grant userB to userA;
那是所有人;-)
另一个要求是在更改对象之前,对象必须由用户userA拥有...