Managing Oracle Synonyms
In your example, FOOBAR
is almost certainly a public synonym. There is no PUBLIC
schema but PUBLIC
is listed as the owner of a public synonym.
If I create a new public synonym
SQL> create public synonym pub_syn_emp 2 for scott.emp;Synonym created.
the owner of that synonym ends up being PUBLIC
SQL> edWrote file afiedt.buf 1 select object_name, owner, object_type 2 from dba_objects 3* where object_name = 'PUB_SYN_EMP'SQL> /OBJECT_NAME OWNER OBJECT_TYP-------------------- ---------- ----------PUB_SYN_EMP PUBLIC SYNONYM
In addition, item #3 does not appear to be correct. If there is a private synonym that points to a non-existent object and a public synonym that points to a valid object, the private synonym still takes precedence. You'll just get an error when Oracle tries to resolve the private synonym to an actual object.
SQL> create synonym syn_emp for scott.no_such_table;Synonym created.SQL> create public synonym syn_emp for scott.emp;Synonym created.SQL> select * from syn_emp;select * from syn_emp *ERROR at line 1:ORA-00980: synonym translation is no longer valid
At least up to 10g, PUBLIC is not a real user. You cannot create objects in the "Public schema":
SQL> CREATE TABLE public.foobar (id integer);CREATE TABLE public.foobar (id integer)ORA-00903: invalid table nameSQL> CREATE TABLE system.foobar (id integer);Table createdSQL>
If you run this query:
SELECT object_name FROM dba_objects WHERE owner='PUBLIC' AND object_type IN ('TABLE', 'VIEW');
You can answer the question about pre-defined tables/views in the PUBLIC "schema".