Link to home
Start Free TrialLog in
Avatar of joaotelles
joaotellesFlag for United States of America

asked on

Oracle 10g - Create synonym

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
Avatar of Alex [***Alex140181***]
Alex [***Alex140181***]
Flag of Germany image

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...
ASKER CERTIFIED SOLUTION
Avatar of johnsone
johnsone
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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".
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.
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 ;-)
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.
Avatar of joaotelles

ASKER

Tks.