Data Dictionary views on Privileges

Posted on 05 February 2008 by Praveen

You have always been scouting inside the database, whether i have privilege for a table or not. What are the privileges available for me ? How to see them ? what are roles assigned to me ? What are the system Privileges to me ? what are the Object privileges available to me ? Well for all your questions…..

Information about privileges that have been granted is stored in the data dictionary. You can use the data dictionary views listed below to list the privileges that have been granted within the database. User-level views are also available.

Data  Dictionary view                                             Data in these views

DBA_ROLES                                                              Names of the roles and their password status

DBA_ROLE_PRIVS                                                  Users who have been granted roles

DBA_SYS_PRIVS                                                     Users who have been granted system privileges

DBA_TAB_PRIVS                                                     Users who have been granted privileges on tables

DBA_COL_PRIVS                                                     Users who have been granted privileges on columns

ROLE_ROLE_PRIVS                                                Role that have been granted to other roles.

ROLE_SYS_PRIVS                                                    System Privileges that have been granted to roles

ROLE_TAB_PRIVS                                                   Table Privileges that have been granted to roles

A user can be granted access to a table by two ways. One is a direct Object Privilege on a table. And the other privileges acquired in the form of roles.

To view the direct privileges on a table



select
 Grantee,
 Owner,
        Table_name,
 privilege,
        Grantable
From
      DBA_TAB_PRIVS
where Grantee='username';     /* replace username with Yours */

To view the table privileges acquired by roles assigned to a user

 SELECT
        A.Grantee,
        b.owner,
        b.table_name,
        b.privilege,
        b.grantable
from  
       DBA_ROLE_PRIVS A, ROLE_TAB_PRIVS B
WHERE
       A.Granted_role=b.Role
   and A.Grantee= 'username'; /* replace username with Yours */

Combining the above to view all the table privileges available for a user

select
 Grantee,
 Owner,
        Table_name,
 privilege,
        Grantable
From
      DBA_TAB_PRIVS
where Grantee='username' /* replace username with Yours */
union
SELECT
        A.Grantee,
        b.owner,
        b.table_name,
        b.privilege,
        b.grantable
from  
       DBA_ROLE_PRIVS A, ROLE_TAB_PRIVS B
WHERE
       A.Granted_role=b.Role
   and A.Grantee= 'username'; /* replace username with Yours */

3 Comments For This Post

  1. B.Kareem Says:

    How want to view procedure privileges granted to a user in oracle 9i.
    Can you give me the command.

  2. Kareem Says:

    want to view procedure privileges granted to a user in oracle 9i.

    Can you give me the command.

  3. B.Kareem Says:

    i want to see what are all the permission granted to a user for procedure

Leave a Reply