Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Oracle 10g - Create synonym

Posted on 2014-09-16
7
Medium Priority
?
665 Views
Last Modified: 2014-09-17
Hi,

Im trying to create a synonym for a table in a dif. schema but I cant access the table even after the synonym creation...

When connected as dpow schema I can see the table:

sqlplus dpow/XXXXX

SQL> desc TS_DCS
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 DCS                                       NOT NULL NUMBER(3)
 VALID                                     NOT NULL NUMBER(1)

So when connected as dpow_1a I cant...

SQL> desc DPOW.TS_DCS
ERROR:
ORA-04043: object DPOW.TS_DCS does not exist

Even after creating this synonym as dpow_1a
CREATE SYNONYM TS_DCS FOR dpow.TS_DCS;
commit;

===

Am I doing anything wrong? Any permission that needs to be set?

Both schemas are in the same DB.

Tks,
Joa
0
Comment
Question by:joaotelles
7 Comments
 
LVL 14

Expert Comment

by:Alexander Eßer [Alex140181]
ID: 40325307
I suppose, you have to "CREATE PUBLIC SYNONYM TS_DCS FOR DPOW.TS_DCS;" as user DPOW
Then you can do a "DESC TS_DCS" as DPOW_1A...
0
 
LVL 35

Accepted Solution

by:
johnsone earned 2000 total points
ID: 40325317
Do not create a public synonym.  If you want a private synonym, that is what you should create.  Public synonyms can create problems.  In this case, the public synonym would generate the same error anyway.

You error is a permission problem.  User DPOW_1A does not have permission on DPOW.TS_DCS.  If you grant permission (probably GRANT SELECT ON TS_DCS TO DPOW_1A as the DPOW user), then it should work fine.

The object does not exist message is a permission message in this case.  The idea is a security message, if it gives you a permission message, then you just guess a correct name of an object in another schema.
0
 
LVL 35

Expert Comment

by:Mark Geerlings
ID: 40326196
Johnsone is correct.  This is a permission (grant) problem, not a synonym problem.  Synonyms and permissions (grants) in Oracle are independent of each other.  If you have the grant, but no synonym, you can still access the table if you use the full [schema].[table_name] syntax.  If you don't have the grant, it doesn't matter if a synonym exists for the table or not - you wan't be able to "describe" it or select its contents.

I do not consider public synonyms to be bad.  I find them to be very helpful for objects that I want to be available across multiple schemas.  These are usually objects that I do grants on to "PUBLIC".
0
Independent Software Vendors: 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!

 
LVL 35

Expert Comment

by:johnsone
ID: 40327716
I have found that for single application databases, public synonyms are fine.  When you add multiple applications, they can become a problem.  If you want to have all public synonyms, then names have to be unique across schemas, which defeats the purpose of multiple schemas to a certain extent.

I don't think public synonyms are bad, just not the remedy to this problem.  There are many people that do consider them bad.  A lot of them are auditors, if you use them be prepared to defend why you need public over private synonyms.  I have had auditors try to get me to drop the public synonym for DUAL and it was a fight to keep it.
0
 
LVL 14

Expert Comment

by:Alexander Eßer [Alex140181]
ID: 40327831
I have had auditors try to get me to drop the public synonym for DUAL and it was a fight to keep it.
Seriously?! I would have beaten the shit out of him/her ;-)
0
 
LVL 35

Expert Comment

by:johnsone
ID: 40327837
I actually asked them if they would support the databases at that point because Oracle wouldn't.  They said no, so I didn't do it.

And, yes, they did ask that.  Said any public synonym or privilege granted to public was a security risk and was required to be dropped.
0
 

Author Closing Comment

by:joaotelles
ID: 40327848
Tks.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
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 explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

773 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