如何检查分配给架构、oracle 数据库中的角色的对象的权限(DDL、DML、DCL)?

Raj*_*esh 2 sql oracle privileges sqlplus

大多数时候,我们都在为获取 Schema、Role 及其对象的权限的详细信息而苦苦挣扎,并尝试找到一些简单的方法来获取有关它的所有详细信息以及伪查询代码以批量生成授权语句以供进一步使用执行。所以在这里我们要得到它。

Raj*_*esh 6

关于数据字典视图前缀的一些简要说明:

ALL_    -Describes PUBLIC Object grants.
USER_   -Describes current user Object grants.
DBA_    -Describes all object grants in the database.
Run Code Online (Sandbox Code Playgroud)

有用的视图信息:

ROLE_ROLE_PRIVS     -describes the roles granted to other roles. 
ROLE_SYS_PRIVS      -describes system privileges granted to roles.
ROLE_TAB_PRIVS      -describes table privileges granted to roles. 
DBA_ROLE_PRIVS      -describes the roles granted to all users and roles in the database.
DBA_SYS_PRIVS       -describes system privileges granted to users and roles.
DBA_TAB_PRIVS       -describes all object grants in the database.
DBA_COL_PRIVS       -describes all column object grants in the database.
Run Code Online (Sandbox Code Playgroud)

要了解有关PRIVS视图的更多信息,请访问此处

查询:

-关于用户/模式状态

select username,account_status, created from dba_users where username in ('SCOTT');
Run Code Online (Sandbox Code Playgroud)

- 检查分配给角色和架构的角色

select * from DBA_ROLE_PRIVS where grantee in ('SCOTT','RESOURCE');
Run Code Online (Sandbox Code Playgroud)

-检查角色权限

select * from ROLE_ROLE_PRIVS where role in ('RESOURCE','CONNECT');    
select * from ROLE_TAB_PRIVS  where role in ('RESOURCE','CONNECT');
select * from ROLE_SYS_PRIVS  where role in ('RESOURCE','CONNECT');

Pseudo Code:
select 'grant '||privilege||' to ROLE_SLAVE;' from ROLE_SYS_PRIVS where role in ('RESOURCE','CONNECT');
select 'grant '||privilege||' to ROLE_SLAVE;' from ROLE_TAB_PRIVS where role in ('RESOURCE','CONNECT');
Run Code Online (Sandbox Code Playgroud)

-检查架构的授予对象的权限

select * from DBA_SYS_PRIVS where grantee in ('SCOTT');
select * from DBA_TAB_PRIVS where grantee in ('SCOTT');
select * from DBA_COL_PRIVS where grantee in ('SCOTT');

Pseudo Code: 
select 'grant '||privilege||' to SCOTT_SLAVE;' from DBA_SYS_PRIVS where grantee in ('SCOTT');
select 'grant '||privilege||' on '||owner||'.'||table_name||' to SCOTT_SLAVE;' from DBA_TAB_PRIVS where grantee in ('SCOTT');
select 'grant '||privilege||' ('||column_name||') '||' on '||owner||'.'||table_name||' to SCOTT_SLAVE;' from DBA_COL_PRIVS where grantee in ('SCOTT');
Run Code Online (Sandbox Code Playgroud)

谢谢你!