Solved

How to create PRIVATE SYNONYM ?

Posted on 2006-11-08
6
5,002 Views
Last Modified: 2010-08-05
Hello,

I have created PUBLIC SYNONYM for tables on a schema without problems.

However, the DBA told me that it's better to create PRIVATE SYNONYM for tables to an specific user.

After dropping PUBLIC SYNONYMs, I tried to do this, but got error:

CREATE PRIVATE SYNONYM Table_1   for MySchema.Table_1 ;

Error: ORA-00922: missing or invalid option

How could I create private synonym for an database user: My_Read_User
0
Comment
Question by:miyahira
6 Comments
 
LVL 14

Expert Comment

by:GGuzdziol
ID: 17898229
just
CREATE SYNONYM
there's no PRIVATE keyword. But this will be private in fact.
0
 
LVL 1

Author Comment

by:miyahira
ID: 17898296
Mmmm... If I try to do:

CREATE SYNONYM Table_1   for MySchema.Table_1 ;

Then got error:
ORA-01471: cannot create a synonym with same name as object

So I do:

CREATE SYNONYM Table_1x   for MySchema.Table_1 ;

And it's OK.

However, when I connect to database as My_Read_User, I have to query like this:
SELECT * FROM MySchema.Table_1x

Is there anyway to connect to database as My_Read_User and query without specifying any schema:
SELECT * FROM Table_1
0
 
LVL 14

Accepted Solution

by:
GGuzdziol earned 80 total points
ID: 17898309
Yes -
CREATE SYNONYM Table_1   for MySchema.Table_1 ;

but run this as My_Read_user
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 32

Assisted Solution

by:awking00
awking00 earned 35 total points
ID: 17898322
create synonym table_1 for myschema.mytable_11082006; => often private synonyms are used create generic names for more complicated ones.

grant select on table_1 to my_read_user;

0
 
LVL 1

Author Comment

by:miyahira
ID: 17898340
Ok, I got it... thanks GGuzdziol
0
 
LVL 7

Assisted Solution

by:Stephen Lappin
Stephen Lappin earned 35 total points
ID: 17898347
You cannot create a (private) synonym with the same name as an object in the schema you are connected to.

You CAN create a (private) synonym for an object in a different schema with teh same name.

You can also create a PUBLIC synonym for an object in any schema using the same name as the object.
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.

Question has a verified solution.

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

Suggested Solutions

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

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