我需要为当前用户(" userA ")提供的grant
选项/技巧是什么,以允许他更改对象'由另一个用户所属的所有者(" userC ")?
更准确地说,联系人表由 userC 拥有,当我执行以下查询以将所有者更改为 userB 时,与 userA 连接:
alter table contact owner to userB;
我收到此错误:
ERROR: must be owner of relation contact
但是 userA 拥有通常所需的所有权利(" 在架构上创建" grant选项应该足够了):
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=>
答案 0 :(得分:78)
感谢Mike的评论,我重新阅读了文档,并且我意识到我当前的用户(即已经拥有创建特权的userA)不是 direct /新拥有角色的间接成员 ...
所以解决方案非常简单 - 我刚刚完成了这笔资助:
grant userB to userA;
这是所有人; - )
<小时/> 的更新强>
另一个要求是在更改对象之前,该对象必须由用户 userA 拥有...
答案 1 :(得分:11)
答案 2 :(得分:-1)
这解决了我的问题:
ALTER TABLE databasechangelog OWNER TO arwin_ash;
ALTER TABLE databasechangeloglock OWNER TO arwin_ash;