Solved

Creating New User to view specific Schema

Posted on 2011-09-22
3
549 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

690 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