Tuesday, April 16, 2013

Grant readonly access to PL/SQL (Function, procedures, packages etc) user logged in through SQL Developer

Sometimes developer need read only access to the code of you PL/SQL in oracle, this is not difficult to achieve. You can create a user
create user readonlyU identified by strongpassword default tablespace users temporary tablespace temp;
grant connect to readonlyU;
grant select on sys.dba_source to readonlyU;

This will work great but if you log in through SQL Developer you will not able to see the PL/SQL objects.

There are two solutions to this problem. After implementation of these solutions readonlyU should be able to view the source code in SQL Developer like the image below:


1. Grant select access to all tables under database and then set O7_DICTIONARY_ACCESSIBILITY=TRUE

This would allow user to have select access on all the tables including data dictionary tables. This could not be the best option.

grant select any table to readonlyU;
alter system set O7_DICTIONARY_ACCESSIBILITY=TRUE scope=spfile;
shutdown immediate
startup

2. SQL Developer us two dba views to show the PL/SQL objects under left navigation and those are dba_objects and dba_plsql_object_settings. Hence granting select on these two views will do the trick.

grant select on sys.dba_objects to readonlyU;
grant select on sys.dba_plsql_object_settings to readonlyU;







No comments: