Solved

How to make synonym useful for all users

Posted on 2004-08-07
4
3,083 Views
Last Modified: 2010-05-18
Hi,
I have a database instance. It has say two users. User1 and User2.
Say User1 has a table Table1. I want it to be made available by User2 in terms of a synonym.
So I create a public synonym using dba priviliges.

create public synonym nt_Table1 for user1.Table1;

Now when I go into User2 and do a select  e.g

Select * from nt_Table1; I am unable to access that data.

But for sys login the same query returns me the data.
Please tell me as to why is this happening? What should I do so that the synonym returns me data even in User2 login.

Regards,
Anand


0
Comment
Question by:anandabrata
  • 2
4 Comments
 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 11743047
You need to GRANT privileges to user (or role) also.

GRANT select on table1 to user2;

or

create role tab_select;
grant select on table1 to tab_select;
grant tab_select to user1;

0
 
LVL 34

Expert Comment

by:Mark Geerlings
ID: 11745004
Synonyms and grants are two different things.  Synonyms are simply a shorter way of refering to an object, so you can use just the object name, rather than the full: "shema.object_name" syntax when you are in a different schema.  But, the Oracle security rules still apply.  User2 cannot access objects in User1's schema whether synonyms exist for them or not, if User1 has not granted permission to User2 to use them.  
0
 
LVL 8

Expert Comment

by:annamalai77
ID: 11750302
hi there

well what u have done is just created an alias for a table. u have give permission to other users who can access the table using the alias name

create public synonym <syn.name> for <tablename>;

grant all on <syn.name> to public;
will grant all priviliges to the table ie select, insert, delete, update for all users.

or

grant select on <syn.name> to public;
will grant select priviliges to the table ie select, insert, delete, update for all users.

or

grant select on <syn.name> to <username>;
will grant select priviliges to the table ie select, insert, delete, update for a specific user.

hope the above solves ur purpose.

regards
annamalai

0
 
LVL 8

Accepted Solution

by:
annamalai77 earned 50 total points
ID: 11750311
correct posting.

hi there

well what u have done is just created an alias for a table. u have give permission to other users who can access the table using the alias name

create public synonym <syn.name> for <tablename>;

grant all on <syn.name> to public;
will grant all priviliges to the table ie select, insert, delete, update for all users.

or

grant select on <syn.name> to public;
grant insert on <syn.name> to public;
grant update on <syn.name> to public;
grant delete on <syn.name> to public;

will grant individual priviliges to the table for all users.

or

grant select on <syn.name> to <username>;
grant insert on <syn.name> to <username>;
grant update on <syn.name> to <username>;
grant delete on <syn.name> to <username>;

will grant individual priviliges for a specific user.

hope the above solves ur purpose.

regards
annamalai

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.

Join & Write a Comment

Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
Via a live example, show how to take different types of Oracle backups using RMAN.

707 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now