Skip to Main Content
  • Questions
  • weird behavior for namespaces of public synonym and normal tables

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Ye.

Asked: March 07, 2017 - 4:09 am UTC

Last updated: March 07, 2017 - 7:29 am UTC

Version: 12g

Viewed 1000+ times

You Asked

Hi ,tom

I am sorry that I proposed a similar question some days ago where I misstated the question. So I describe here again , correctly.


I am currently working with synonym in oracle and find the fact that:

SQL> create public synonym mysynonym for myschema.mytable;
Synonym created.

SQL> create table myschema.mysynonym(a int);
//a table who has the same name with public synonym
ERROR at line 1:
ORA-00955: name is already used by an existing object


According to the doc of oracle described here, it is quite reasonable:

https://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_7001.htm

yeah, it is quite reasonable, expected. but I find that 'vice versa' does not hold here:

SQL> create table myschema.mysynonym(a int);
Table created. //create a table whose name is "mysynonym" firstly

SQL> create public synonym mysynonym for myschema.mytable;

Synonym created.
// and then create a public synonym with the same name of the table.
// wow, succeed. IMHO, it should have been failed.



would you please help me figure out why ?

thanks a lot.

and Connor said...

Sorry, I can't reproduce your error

SQL> create public synonym mysynonym for mcdonac.mytable;

Synonym created.

SQL> create table mcdonac.mysynonym(a int);

Table created.




Is this answer out of date? If it is, please let us know via a Comment