Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to create PRIVATE SYNONYM ?

Posted on 2006-11-08
6
5,007 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

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

860 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