Solved

How to make synonym useful for all users

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Can't Access My Database 57 84
run sql script from putty 4 159
SQL Workhours Count beetween Workhours 3 39
oracle date format checking 7 31
Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
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…
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

685 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