Solved

Creating New User to view specific Schema

Posted on 2011-09-22
3
542 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 76

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 73

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 34

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
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.
This video shows how to recover a database from a user managed backup

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now