pgsql的schema对用户授权,单个用户跨schema增删改查操作


--创建用户
create user user1;
--修改密码
alter user report with password 'password';


--授权查询权限
grant usage on schema schema1 to user1;
grant usage on schema schema2 to user1;


修改search_path可跨schema操作
set search_path = "$user",user1,user2


--授权schema:schema1给user1权限 这个权限太大需要慎用
grant all on schema schema1 to user1;


--授权schema的表权限给user1 用户权限太多需慎用
grant all on all tables in schema schema1 to user1;

 

--授权schema的表权限给user1 用户权限太多需慎用
grant all on all tables in schema schema1 to user1;


--授权某个schema的单个表查权限 
grant select on schema2.table1                     to user1;


--收回所有授权
revoke all on all tables in schema schema1 from user1;


--为某个特定用户设置search_path
alter user user1 set search_path="$user",user1,user2;

你可能感兴趣的:(pgsql的schema对用户授权,单个用户跨schema增删改查操作)