I have a public synonym on my server for transactions: However I’d like to be able to work with my own local version of the table, so as not to disturb other users.
Does Oracle’s SQL resolve naming conflicts like this in a predictable fashion?
In other words, if another user creates a public synonym called TRANSACTION and I do this:
CREATE TABLE TRANSACTION (
ID NUMBER
);
When I write
select * from TRANSACTION
Do I have any guarantee that Oracle will always resolve the synonym or my local table?
(I know I could technically specify schema.TRANSACTION to force the issue, but in my case that would require me to modify/rebuild an application and I’m hoping to save some work.)
Your understanding of name resolution is correct. Oracle will first look in the current schema to find an object with that name. So, In case of a conflict, It will choose an object in the current schema instead of the object referred to by the public synonym.
http://docs.oracle.com/cd/B28359_01/server.111/b28310/general008.htm
Having said that, this is one of the problems with public synonyms. Having objects like this will lead to confusion down the road, both for development and support. You are better off referencing the object by owner and name in both cases