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
Solved

How to make synonym useful for all users

Posted on 2004-08-07
4
3,086 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 35

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Oracle Pivot Question 8 71
Oracle SQL syntax check  without executing 6 75
Oracle dataguard 5 46
Error in creating a view. 8 23
This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
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…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
This video shows how to recover a database from a user managed backup

828 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