Solved

Creating New User to view specific Schema

Posted on 2011-09-22
3
547 Views
Last Modified: 2013-12-19
Good day Oracle Experts:

I have a Schema called SAPDEV which has about 2000 tables in it.

I would like to create a new user called GMASTERS  that has SELECT only on all the SAPDEV schema with connect privliges only.  Can you give me a good example on how I would do this?

Thank you for your time today
0
Comment
Question by:algotube
3 Comments
 
LVL 77

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 50 total points
ID: 36581539
I would create a role say readonly.

Grant select on the tables to readonly, then grant that role to gmasters.

I would also suggest creating synonyms so gmasters doesn't need to fully qualify the tables.
0
 
LVL 74

Accepted Solution

by:
sdstuber earned 200 total points
ID: 36581598
create role READ_SAPDEV_ROLE;

create user GMASTERS identified by pa55w0rd;

grant connect to READ_SAPDEV_ROLE;

DECLARE
    v_grantee VARCHAR2(30) := 'READ_SAPDEV_ROLE';
    v_owner   VARCHAR2(30) := 'SAPDEV';
BEGIN
    FOR x
    IN (SELECT    'grant select on "'              
               || owner
               || '"."'
               || object_name
               || '" to '
               || v_grantee
                   grant_sql
          FROM dba_objects
         WHERE owner = v_owner
           AND object_type IN ('TABLE', 'VIEW'))   -- remove VIEW if you want tables only
    LOOP
        EXECUTE IMMEDIATE x.grant_sql;
    END LOOP;
END;


grant READ_SAPDEV_ROLE to GMASTERS;
0
 
LVL 35

Expert Comment

by:johnsone
ID: 36581987
Just be aware with these approaches that if a new table is added to the SAPDEV schema privileges need to be granted on the new table to the user or role.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question