如何授予当前用户(“userA”)更改属于另一个用户(“userC”)拥有的对象所有者的权限/技巧?
更具体地说,contact表由userC拥有,当我执行以下查询以将所有者更改为与userA连接的userB时:
alter table contact owner to userB;
我遇到了这个错误:
ERROR: must be owner of relation contact
但是用户A通常拥有执行此操作所需的所有权限(“在架构上创建”授权选项应该足够):
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;
命令行输出:
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=>
alter table
,只需运行此命令即可解决问题。我将此命令理解为grant createUser to alterUser;
,其中createUser
是创建我的表的人,而alterUser
则是试图更改它的人。我遇到了这个问题,因为我们在配置中更改了DB用户,而DB中有一些现有的表格。 - Swapnil Chincholkar