pgsql grant语句针对属性授予权限

教材上的 GRANT 语句格式为:

grant <权限列表> on <数据库对象> to <用户或角色> [ with grant option ]; 

授权选项:允许该用户或角色将自己被授予的权限授予其它用户或角色。使用如下:

grant <权限列表> on <数据库对象> to <用户或角色> with grant option; 

教材上只谈到了针对关系表的权限,例如:

grant select on book to "R_Customer";

并没有谈到针对部分属性的权限,直到我看到了一道复习题,如下:

我表示很震惊,从来没见过这种操作。于是打开 PgAdmin 试了一下,发现确实可以。

① 首先给角色 R_Customer 授权,让它能够修改 book 中的 title 属性:

grant update(title) on book to "R_Customer";

② 登录用户 U_Customer,过程略,U_Customer 是属于 R_Customer 的。

③ 测试是否能够 update:

update book set title='数据库原理与实践' where isbn='1111111111111';

过程截图如下:


因此进一步 GRANT 语句格式可以为:

grant <权限列表>(<数据库对象的属性>) on <数据库对象>
to <用户或角色> [ with grant option ]; 

猜你喜欢

转载自blog.csdn.net/m0_64140451/article/details/131049722