Thursday, March 22, 2012

How to Grant on Data Dictionary v$ views

There can be requirement when we as a DBA wanted to give access to some v$session or v$process or any other dictionary view to other users for any reason.

We can do it in following way

SQL> grant select on v_$SESSION to TEST;

Grant succeeded.

If we do

SQL> grant select on v$session to TEST;
grant select on v$session to TEST
                *
ERROR at line 1:
ORA-02030: can only select from fixed tables/views

Now why second command failed?

Because v$ is a synonym and v$_ is a view. So we cannt give grants to synonym.

See below
SQL> select object_name,object_type from dba_objects where object_name='V$SESSIO
N';

OBJECT_NAME
--------------------------------------------------------------------------------

OBJECT_TYPE
-------------------
V$SESSION
SYNONYM


SQL> select object_name,object_type from dba_objects where object_name='V_$SESSI
ON';

OBJECT_NAME
--------------------------------------------------------------------------------

OBJECT_TYPE
-------------------
V_$SESSION
VIEW

So in general we can give select grants to view i.e. v_$ not to synonym v$

No comments:

Post a Comment