¿Cómo encontrar los privilegios y roles otorgados a un usuario en Oracle?


Estoy usando Linux, Oracle10g. He creado un usuario llamado test. y concedido crear sesión y seleccionar cualquier permiso diccionario para el mismo usuario.

También concedí roles sysdba y sysoper a los mismos usuarios.

Ahora quiero mostrar todos los privilegios y roles otorgados al usuario. Encontré la siguiente consulta, pero solo muestra crear sesión y seleccionar privilegios de diccionario.

select privilege 
from dba_sys_privs 
where grantee='SAMPLE' 
order by 1;

Por favor, ayude a resolver el problema.

Gracias

Author: APC, 2013-02-25

8 answers

Mira http://docs.oracle.com/cd/B10501_01/server.920/a96521/privs.htm#15665

Compruebe las tablas USER_SYS_PRIVS, USER_TAB_PRIVS, USER_ROLE_PRIVS.

 36
Author: VAV,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-02-25 12:01:43

Además de la respuesta de VAV, la primera fue más útil en mi entorno

select * from USER_ROLE_PRIVS where USERNAME='SAMPLE';
select * from USER_TAB_PRIVS where Grantee = 'SAMPLE';
select * from USER_SYS_PRIVS where USERNAME = 'SAMPLE';
 55
Author: user2668478,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-01-15 21:42:38

Ninguna de las otras respuestas funcionó para mí, así que escribí mi propia solución:

A partir de Oracle 11g.

Reemplazar USUARIO con el nombre de usuario deseado

Roles concedidos:

SELECT * 
  FROM DBA_ROLE_PRIVS 
 WHERE GRANTEE = 'USER';

Privilegios Otorgados Directamente Al Usuario:

SELECT * 
  FROM DBA_TAB_PRIVS 
 WHERE GRANTEE = 'USER';

Privilegios Otorgados al Rol Otorgado al Usuario:

SELECT * 
  FROM DBA_TAB_PRIVS  
 WHERE GRANTEE IN (SELECT granted_role 
                     FROM DBA_ROLE_PRIVS 
                    WHERE GRANTEE = 'USER');

Privilegios concedidos al Sistema:

SELECT * 
  FROM DBA_SYS_PRIVS 
 WHERE GRANTEE = 'USER';

Si desea buscar el usuario con el que está conectado actualmente, puede reemplazar DBA en el nombre de la tabla con USER y eliminar la cláusula WHERE.

 30
Author: Mocking,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-05-25 02:31:50

SI se otorgan privilegios a un usuario a través de algunos roles, entonces debajo de SQL se puede usar

select * from ROLE_ROLE_PRIVS where ROLE = 'ROLE_NAME';
select * from ROLE_TAB_PRIVS  where ROLE = 'ROLE_NAME';
select * from ROLE_SYS_PRIVS  where ROLE = 'ROLE_NAME';
 9
Author: upog,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-12-16 15:28:53

Combinando las sugerencias anteriores para determinar sus permisos personales (es decir, permisos de' USUARIO'), luego use esto:

-- your permissions
select * from USER_ROLE_PRIVS where USERNAME= USER;
select * from USER_TAB_PRIVS where Grantee = USER;
select * from USER_SYS_PRIVS where USERNAME = USER;

-- granted role permissions
select * from ROLE_ROLE_PRIVS where ROLE IN (select granted_role from USER_ROLE_PRIVS where USERNAME= USER);
select * from ROLE_TAB_PRIVS  where ROLE IN (select granted_role from USER_ROLE_PRIVS where USERNAME= USER);
select * from ROLE_SYS_PRIVS  where ROLE IN (select granted_role from USER_ROLE_PRIVS where USERNAME= USER);
 6
Author: ShamrockCS,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-10-28 16:49:57
select * 
from ROLE_TAB_PRIVS 
where role in (
    select granted_role
    from dba_role_privs 
    where granted_role in ('ROLE1','ROLE2')
)
 1
Author: shans,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-06-18 16:04:38
SELECT * 
FROM DBA_ROLE_PRIVS 
WHERE UPPER(GRANTEE) LIKE '%XYZ%';
 0
Author: user2615480,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-07-24 16:40:33

Siempre haga que SQL sea reutilizable: -:)

-- ===================================================
-- &role_name will be "enter value for 'role_name'".
-- Date:  2015 NOV 11.

-- sample code:   define role_name=&role_name
-- sample code:   where role like '%&&role_name%'
-- ===================================================


define role_name=&role_name

select * from ROLE_ROLE_PRIVS where ROLE = '&&role_name';
select * from ROLE_SYS_PRIVS  where ROLE = '&&role_name';


select role, privilege,count(*)
 from ROLE_TAB_PRIVS
where ROLE = '&&role_name'
group by role, privilege
order by role, privilege asc
;
 0
Author: dave,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-11-11 23:23:40