?
Solved

How to create PRIVATE SYNONYM ?

Posted on 2006-11-08
6
Medium Priority
?
5,067 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
[X]
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
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 320 total points
ID: 17898309
Yes -
CREATE SYNONYM Table_1   for MySchema.Table_1 ;

but run this as My_Read_user
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
LVL 32

Assisted Solution

by:awking00
awking00 earned 140 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 140 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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 post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
Suggested Courses

752 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