`

Users to roles and system privileges

阅读更多
This is a script that shows the hierarchical relationship between system privileges, roles and users.
It makes use of Oracles connect by SQL idiom.
Vladimir Gabzovski notifies me, that the following script doesn't run on 8.1 (ORA-01472). I want to thank him for pointing this out.
select
  lpad(' ', 2*level) || granted_role "User, his roles and privileges"
from
  (
  /* THE USERS */
    select 
      null     grantee, 
      username granted_role
    from 
      dba_users
    where
      username like upper('%&enter_username%')
  /* THE ROLES TO ROLES RELATIONS */ 
  union
    select 
      grantee,
      granted_role
    from
      dba_role_privs
  /* THE ROLES TO PRIVILEGE RELATIONS */ 
  union
    select
      grantee,
      privilege
    from
      dba_sys_privs
  )
start with grantee is null
connect by grantee = prior granted_role;

System privileges to roles and users

This is also possible the other way round: showing the system privileges in relation to roles that have been granted this privilege and users that have been granted either this privilege or a role:
select
  lpad(' ', 2*level) || c "Privilege, Roles and Users"
from
  (
  /* THE PRIVILEGES */
    select 
      null   p, 
      name   c
    from 
      system_privilege_map
    where
      name like upper('%&enter_privliege%')
  /* THE ROLES TO ROLES RELATIONS */ 
  union
    select 
      granted_role  p,
      grantee       c
    from
      dba_role_privs
  /* THE ROLES TO PRIVILEGE RELATIONS */ 
  union
    select
      privilege     p,
      grantee       c
    from
      dba_sys_privs
  )
start with p is null
connect by p = prior c;

Object privileges

select
  case when level = 1 then own || '.' || obj || ' (' || typ || ')' else
  lpad (' ', 2*(level-1)) || obj || nvl2 (typ, ' (' || typ || ')', null)
  end
from
  (
  /* THE OBJECTS */
    select 
      null          p1, 
      null          p2,
      object_name   obj,
      owner         own,
      object_type   typ
    from 
      dba_objects
    where
       owner not in 
        ('SYS', 'SYSTEM', 'WMSYS', 'SYSMAN','MDSYS','ORDSYS','XDB', 'WKSYS', 'EXFSYS', 
         'OLAPSYS', 'DBSNMP', 'DMSYS','CTXSYS','WK_TEST', 'ORDPLUGINS', 'OUTLN')
      and object_type not in ('SYNONYM', 'INDEX')
  /* THE OBJECT TO PRIVILEGE RELATIONS */ 
  union
    select
      table_name p1,
      owner      p2,
      grantee,
      grantee,
      privilege
    from
      dba_tab_privs
  /* THE ROLES TO ROLES/USERS RELATIONS */ 
  union
    select 
      granted_role  p1,
      granted_role  p2,
      grantee,
      grantee,
      null
    from
      dba_role_privs
  )
start with p1 is null and p2 is null
connect by p1 = prior obj and p2 = prior own;
分享到:
评论

相关推荐

    两天成为Oracle_DBA(PDF版)

    about using system privileges and roles to control user access to the database. Chapter 8, "Managing Schema Objects" This chapter discusses managing tables, indexes, and other schema objects. Chapter ...

    Solaris 10 System Administration Essentials

    11.1 Solaris Users, Groups, and Roles 309 11.1.1 File System Object Permissions 310 11.1.2 User Account Components 312 11.1.3 User Management Tools 313 11.1.4 User Management Files 313 11.2 Managing ...

    Oracle Security

    Chapter 5 Oracle Default Roles and User Accounts About the Defaults The CONNECT Role The RESOURCE Role The DBA Role The SYSDBA and SYSOPER Roles Using the Default Roles Default User Accounts ...

    a project model for the FreeBSD Project.7z

    The vision is “To produce the best UNIX-like operating system package possible, with due respect to the original software tools ideology as well as usability, performance and stability.” The ...

    Oracle课堂笔记重点

    1. 用户与角色(Users and Roles):用户是访问数据库的实体,角色是一组权限的集合,可简化权限管理。 2. 权限(Privileges):授予用户执行特定操作的权限,如SELECT、INSERT、UPDATE、DELETE等。 3. 系统权限...

    Oracle 用户权限

    根据提供的文件信息,我们可以深入探讨Oracle数据库中的用户权限管理机制,包括系统权限(System Privileges)与对象权限(Object Privileges)的相关知识点。 ### 一、系统权限(System Privileges) 系统权限是...

    ORACLE资料

    4. 系统权限(System Privileges):全局权限,如CREATE TABLE、ALTER USER等。 5. 对象权限(Object Privileges):针对特定对象的权限,如对某个表的SELECT权限。 七、Oracle备份与恢复 1. 热备份(Hot Backup)...

    ORACLE 培训课件 很详细的 管理方向

    8. 用户(Users)、权限(Privileges)和角色(Roles)管理: - 用户管理涉及创建、修改和删除用户账户,以及设定默认表空间。 - 权限管理确保用户只能访问他们被授权的操作。 - 角色是权限的集合,简化权限管理...

    Oracle体系结构

    5. **系统权限(System Privileges)**:对整个数据库的操作权限,如CREATE TABLE、ALTER USER等。 四、数据存储与查询 1. **表(Tables)**:存储数据的基本结构,由列和行组成。 2. **索引(Indexes)**:加快...

    最完整的Toad For Oracle使用手册

    - **Window Privileges and Toad**:解释了窗口权限如何影响Toad的使用。 - **Toad for Oracle, Read-Only**:讨论了只读模式下的Toad使用限制。 - **Registering Toad**:说明了如何注册Toad。 - **Silent ...

    oracle知识8

    2. 安全性:Oracle提供角色(Roles)、用户(Users)和权限(Privileges)机制来控制对数据库资源的访问。此外,还有审计(Auditing)功能用于追踪数据库活动。 3. 备份与恢复:Oracle支持多种备份策略,如完整备份...

    oracle配置

    9. **Managing Users, privileges, roles**: - 用户管理涉及创建、删除用户,分配权限和角色,以及管理口令策略。 - 角色可以集合一组权限,方便权限管理并提高安全性。 Oracle的发展历程从6.0到9i,不断引入新...

    oracle详细介绍(中英对照)

    1. 实例(Instance):实例是由内存结构(如System Global Area, PGA, UGA)和后台进程组成。SGA主要包括数据缓冲区、重做日志缓冲区、共享池等组件,负责缓存数据和执行数据库操作。 2. 数据库(Database):数据库...

    oracle数据库基础ppt

    2. SGA(System Global Area):实例共享的内存区域,包含数据缓冲区、重做日志缓冲区、PGA等。 3. PGA(Program Global Area):每个服务器进程和后台进程私有的内存区域。 4. 后台进程:如DBWR(数据库写入进程)...

Global site tag (gtag.js) - Google Analytics