课后作业
1.创建角色role1为系统管理员, role2指定生效日期, role3具有LOGIN属性
omm=# CREATE ROLE role1 LOGIN SYSADMIN IDENTIFIED BY 'yangkai_123';
NOTICE: The encrypted password contains MD5 ciphertext, which is not secure.
CREATE ROLE
omm=# CREATE ROLE role2 WITH LOGIN PASSWORD 'yangkai_123' VALID BEGIN '2021-12-06' valid UNTIL '2021-12-30';
NOTICE: The encrypted password contains MD5 ciphertext, which is not secure.
CREATE ROLE
omm=# CREATE ROLE role3 LOGIN PASSWORD 'yangkai_123';
NOTICE: The encrypted password contains MD5 ciphertext, which is not secure.
CREATE ROLE
omm=# \du role2;
List of roles
Role name | Attributes | Member of
-----------+-----------------------------------------+-----------
role2 | Role valid begin 2021-12-06 00:00:00+08+| {}
| Role valid until 2021-12-30 00:00:00+08 |
2.重命名role1
omm=# alter role role1 rename to yangkai;
NOTICE: MD5 password cleared because of role rename
ALTER ROLE
3.修改role2密码
romm=# alter role role2 IDENTIFIED BY 'yangkai_456' replace 'yangkai_123';
NOTICE: The encrypted password contains MD5 ciphertext, which is not secure.
omm=# ALTER ROLE
4.将omm权限授权给role3,再回收role3的权限
omm=# grant omm to role3 with admin option;
GRANT ROLE
omm=# revoke all privilege from role3;
ALTER ROLE
5.删除所有创建角色
查看角色
omm=# \du role2;
List of roles
Role name | Attributes | Member of
-----------+-----------------------------------------+-----------
role2 | Role valid begin 2021-12-06 00:00:00+08+| {}
| Role valid until 2021-12-30 00:00:00+08 |
omm=# \du+ role2;
-----------+-----------------------------------------+-----------+-------------
role2 | Role valid begin 2021-12-06 00:00:00+08+| {} |
| Role valid until 2021-12-30 00:00:00+08 | |
omm=# List of roles
Role name | Attributes | Member of | Description
omm=# \du+
List of roles
Role name | Attributes | Member of | D
escription
-----------+------------------------------------------------------------------------------------------------------------------+-----------+--
-----------
gaussdb | Sysadmin | {} |
omm | Sysadmin, Create role, Create DB, Replication, Administer audit, Monitoradmin, Operatoradmin, Policyadmin, UseFT | {} |
role2 | Role valid begin 2021-12-06 00:00:00+08 +| {} |
| Role valid until 2021-12-30 00:00:00+08 | |
role3 | | {omm} |
yangkai | Sysadmin
删除角色:
omm=# drop role yangkai;
DROP ROLE
omm=# drop role role2;
DROP ROLE
omm=# drop role role3;
DROP ROLE
omm=#




