Search code examples
sqloracle-databaseprivileges

On Oracle, I cannot grant select privilege on v$Session to another user


As the 'SYS' user, I can run the following command:

SYS> grant SELECT on V_$SESSION to "SOMEUSER" with GRANT OPTION;

Then, as that user, I can select from V$SESSION:

SOMEUSER> select * from V$SESSION;
 .....  Expected output .....

However, even though the user was given the GRANT option, I cannot GRANT that privilege to anyone else:

SOMEUSER> grant SELECT on V_$SESSION to "OTHERUSER" with GRANT OPTION;
grant select on V_$SESSION to "OTHERUSER"
                *
ERROR at line 1:
ORA-00942: table or view does not exist

Strangely though, I can do this:

SOMEUSER> grant select on V$SESSION to "OTHERUSER";

Grant succeeded.

Why do I have to specify V_$SESSION when running as the SYS user, but when running as a normal user, I have to specify V$SESSION?


Solution

  • The object is sys.v_$session. If you are logged in as someuser, v_$session would be resolved in the current schema, i.e. someuser.v_$session. That object doesn't exist, hence the error

    grant select on sys.v_$session ...
    

    should work.