Solved

How to make synonym useful for all users

Posted on 2004-08-07
4
3,091 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
[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
  • 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.

734 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