Solved

Oracle 10g - Create synonym

Posted on 2014-09-16
7
586 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 13

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 34

Accepted Solution

by:
johnsone earned 500 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
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.

 
LVL 34

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 13

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 34

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
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.
Via a live example, show how to take different types of Oracle backups using RMAN.

791 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