gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 09:13:07 25 4
gpt4 key购买 nike

大多数时候,我们都在与愚蠢的事情作斗争,以获取模式、角色及其对象的特权细节,并尝试找到一些简单的方法来获取所有细节以及伪查询代码以生成授权语句散装以供进一步执行。所以在这里我们要得到它。

最佳答案

关于数据字典 View 前缀的简要说明:

ALL_    -Describes PUBLIC Object grants.
USER_ -Describes current user Object grants.
DBA_ -Describes all object grants in the database.

有用的 View 信息:

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.

要了解有关 PRIVS View 的更多信息,请访问 here .

查询:

-关于用户/模式状态

select username,account_status, created from dba_users where username in ('SCOTT');

-检查分配给角色和模式的角色

select * from DBA_ROLE_PRIVS where grantee in ('SCOTT','RESOURCE');

-检查角色权限

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');

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

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');

谢谢!

关于sql - 如何检查分配给 oracle 数据库中模式、角色的对象的权限(DDL、DML、DCL)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49840745/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com