【发布时间】:2025-12-13 05:50:02
【问题描述】:
什么是grant 选项/技巧我需要给当前用户(“userA”)以允许他更改属于另一个用户的对象的所有者(“用户C")?
更准确地说,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;
感谢
命令行输出:
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=>
【问题讨论】:
标签: postgresql grant