[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Read only database link in oracle database

Posted on 2012-03-27
12
Medium Priority
?
1,645 Views
Last Modified: 2012-05-02
Hello all,

I have one database say 'A' and  there is a table called 'tb1' under a schema 'SC1'.
if there is another database called 'B'  in another server and there is a schema 'SC2'. My requirement is  to give the read-only access to the table 'tb1' in SC1 from  the schema 'SC2' in database 'B'? can you please suggest how to make this work?
0
Comment
Question by:bhanu823
[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
  • 7
  • 3
12 Comments
 
LVL 74

Accepted Solution

by:
sdstuber earned 2000 total points
ID: 37772625
in A -

create a user READ_TB1_USER that has select privilege on SC1.TB1 and create session and no other privileges.

create user read_tb1_user identified by pa55w0rd;
grant select on sc1.tb1 to read_tb1_user;
grant create session to read_tb1_user;

Open in new window




in B - create a private db link to A connecting as READ_TB1_USER


create database link tb1_link
connect to read_tb1_user
identified by "pa55w0rd"
using 'B';

Open in new window

0
 
LVL 74

Expert Comment

by:sdstuber
ID: 37772647
you could create a role in A to contain the privileges and assign the role to the new user instead of direct assignment.

also, you might want to create a private synonym owned by the new user that points to sc1.tb1,  that way the B user doesn't need to know or use the remote schema
0
 

Author Comment

by:bhanu823
ID: 37772748
I didn't unserstand exactly the seconf one. can you please elaborate syntactically?
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
LVL 74

Expert Comment

by:sdstuber
ID: 37772801
create role test_role;
grant select on sc1.tb1 to test_role;
grant create session to test_role;
grant test_role to read_tb1_user;
create synonym tb1 for sc1.tb1;
0
 

Author Comment

by:bhanu823
ID: 37772828
yss..if yu create a synonym to that new user ..then how the SC2 schema  in B database can see the table 'tb1' under SC1 schema in the different database '.B'..    
SC2 schema should query something from the SC1.TB1, rather than read_tb1_user
USER
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 37772839
I'm not sure what you're asking; but if you don't want to use the synonym,  that's fine.

like the role,  it's entirely optional
0
 

Author Comment

by:bhanu823
ID: 37772871
No..I am saying about your 1st solution..creating another user and granting select to that table..in this way the SCHEMA in 'B' dataabase has to query something like  SC1.TB1..i thnk with your answer the schema in 'B' wil select something like 'SC1.read_tb1_user'(WITH THE NEW CREATED USER?)
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 37772882
in B


select * from sc1.tb1@tb1_link


the other user is never referenced in the sql,  it only exists for the purpose of limiting the db link privileges
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 37772885
or,  if you create the synonym in A owned by read_tb1_user


in B


select * from tb1@tb1_link
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 37801252
why the B?  

Penalty grades are not appropriate if you haven't asked for followup.  Especially when they lack explanation as to what is missing
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

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…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
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…

650 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