Solved

Creating New User to view specific Schema

Posted on 2011-09-22
3
544 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.

Question has a verified solution.

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

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

773 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