How To Get The Roles, Privileges And Permissions For A User

Normally to see what permissions have a user in the database usually run the following queries.

 

SELECT * FROM DBA_ROLE_PRIVS WHERE GRANTEE = ‘ANR’;
SELECT * FROM DBA_SYS_PRIVS WHERE GRANTEE = ‘ANR’;
SELECT * FROM DBA_TAB_PRIVS WHERE GRANTEE = ‘ANR’;

 

The first query gives us the associated roles, the second gives us the  system privileges and with the third we get the access and permissions on objects.  Now if what we want are the DDL we can get them in a simple way, using  the DBMS_METADATA  package, respectively;

 

SELECT DBMS_METADATA.GET_GRANTED_DDL(‘ROLE_GRANT’, ‘ANR’) FROM DUAL;
SELECT DBMS_METADATA.GET_GRANTED_DDL(‘SYSTEM_GRANT’,’ANR’) FROM DUAL;
SELECT DBMS_METADATA.GET_GRANTED_DDL(‘OBJECT_GRANT’,’ANR’) FROM DUAL;

 

Summarizing;

DBMS_METADATA.GET_GRANTED_DDL (PARAM1, PARAM2)

PARAM1

  • ROLE_GRANT for roles
  • SYSTEM_GRANT for privileges
  • OBJECT_GRANT for permissions

PARAM2

  • The user

 

HTH – Antonio NAVARRO

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s