扫码一下
查看教程更方便
角色是一个数据库对象,它将多个权限组合在一起,这些权限可以使用 grant
语句分配给用户、组、public
或其他角色。
创建新角色
db2 create role
创建一个名为“sales”的新角色以添加一些由某些用户或组管理的表
db2 create role sales
db20000i the sql command completed successfully.
授予角色对表的权限
db2 grant select on table to role
将管理表 shope.books
的权限添加到角色“sales”
db2 grant select on table shope.books to role sales
db20000i the sql command completed successfully.
安全管理员向所需用户授予角色。 (在使用此命令之前,需要创建用户。)
将用户添加到角色
db2 grant role to user
将用户 mastanvali
添加到角色“sales”
db2 grant sales to user mastanvali
db20000i the sql command completed successfully.
为了为角色创建层次结构,每个角色都被授予另一个角色的权限/成员资格。
在此语法之前创建一个名称为“production”的新角色
db2 grant role to role
将角色“sales”的权限提供给另一个角色“production”
db2 grant sales to role production