[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1787
  • Last Modified:

Read only database link in oracle database

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
bhanu823
Asked:
bhanu823
  • 7
  • 3
1 Solution
 
sdstuberCommented:
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
 
sdstuberCommented:
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
 
bhanu823Author Commented:
I didn't unserstand exactly the seconf one. can you please elaborate syntactically?
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
sdstuberCommented:
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
 
bhanu823Author Commented:
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
 
sdstuberCommented:
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
 
bhanu823Author Commented:
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
 
sdstuberCommented:
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
 
sdstuberCommented:
or,  if you create the synonym in A owned by read_tb1_user


in B


select * from tb1@tb1_link
0
 
sdstuberCommented:
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 7
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now