Solved

Oracle 10g - Create synonym

Posted on 2014-09-16
7
542 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 34

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

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.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Oracle queries --Challenging Question 12 63
Pl/SQL Query 31 61
oracle rollup query 3 37
Oracle DATE Column Space 11 44
Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
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…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This video shows how to recover a database from a user managed backup

705 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now