Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Creating New User to view specific Schema

Posted on 2011-09-22
3
Medium Priority
?
563 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 200 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 800 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
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 recover a database from a user managed backup

597 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