I
I
IvankoPo2018-09-17 16:58:03
Oracle
IvankoPo, 2018-09-17 16:58:03

How to create a request to select privileges by users?

There is a system user (SYSTEM) in the Oracle database and let's say my user my_user to which I assigned certain rights
, so you need to make a query that would display a table of this kind (dots are a space filler)
+------------ ---------------+----------+-----------+
| Privilege name | SYSTEM | my_user |
+--------------------------------+----------+---------- -+
| create table....|..YES.......|...YES......|
+--------------------------------+----------+---------- -+
| create index.................|..YES......|...NO........|
+--------------------------------+----------+---------- -+
etc
That is, the name of the privilege is the first column, the second YES or NO does the user SYSTEM have this privilege and the 3rd column YES or NO does the user my_user have this privilege
Help write a query, which tables it needs to be done, how to present data from them in in this form?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
idShura, 2018-09-18
@idShura

So?

SELECT T1.PRIVILEGE, 
       T1.ADMIN_OPTION  SYS_USER,
       T2.ADMIN_OPTION  MY_USER 
  FROM DBA_SYS_PRIVS T1 
       LEFT JOIN DBA_SYS_PRIVS T2 ON T1.PRIVILEGE = T2.PRIVILEGE 
                           AND T2.GRANTEE = 'MY_USER'
  WHERE T1.GRANTEE = 'SYS'
  ORDER BY T1.PRIVILEGE ASC

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question