1.创建角色role1为系统管理员, role2指定生效日期, role3具有LOGIN属性
create role role1 with sysadmin identified by 'test_123';
create role role2 identified by 'test_123' valid begin '2021-12-04';
create role role3 with login identified by 'test_123';
omm=# \du+ role1
List of roles
Role name | Attributes | Member of | Description
-----------+------------------------+-----------+-------------
role1 | Cannot login, Sysadmin | {} |
omm=# \du+ role2
List of roles
Role name | Attributes | Member of | Description
-----------+-----------------------------------------+-----------+-------------
role2 | Cannot login +| {} |
| Role valid begin 2021-12-04 00:00:00+08 | |
omm=# \du+ role3
List of roles
Role name | Attributes | Member of | Description
-----------+------------+-----------+-------------
role3 | | {} |
2.重命名role1
alter role role1 rename to role10;
3.修改role2密码
alter role role2 identified by 'test_1234';
4.将omm权限授权给role3,再回收role3的权限
grant omm to role3;omm=# \du+ role3
omm=# List of roles
Role name | Attributes | Member of | Description
-----------+------------+-----------+-------------
role3 | | {omm} |
revoke all privilege from role3;
omm=# \du+ role3;
List of roles
Role name | Attributes | Member of | Description
-----------+------------+-----------+-------------
role3 | | {omm} |
5.删除所有创建角色
drop role role1;
drop role role2;
drop role role3;
过程中使用\du或\du+查看角色信息
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




