--private synonym私有同义词
HR@prod> create synonym d for departments;

Synonym created.

HR@prod> delete from d where department_id=270;

1 row deleted.

HR@prod> rollback;

Rollback complete.

--public synonym 共有同义词
HR@prod> conn / as sysdba
Connected.
SYS@prod> grant create public synonym to hr;  -- 授权

Grant succeeded.

SYS@prod> conn hr/hr
Connected.
HR@prod> create public synonym d_pub for departments;

Synonym created.

--同义词的查询
HR@prod> col synonym_name for a20
HR@prod> col table_owner for a20
HR@prod> col table_name for a20
HR@prod> col db_link for a10
HR@prod> select * from user_synonyms;     ==查询私有同义词

SYNONYM_NAME      TABLE_OWNER   TABLE_NAME        DB_LINK
-------------------- -------------------- -------------------- ----------
D       HR     DEPARTMENTS        (null)


--查询共有同义词
HR@prod> select * from all_synonyms where synonym_name='D_PUB';

OWNER          SYNONYM_NAME     TABLE_OWNER   TABLE_NAME       DB_LINK
------------------------------ -------------------- -------------------- -------------------- ----------
PUBLIC          D_PUB      HR    DEPARTMENTS       (null)


--当前的同义词
HR@prod> select synonym_name,owner from all_synonyms where synonym_name in('D','D_PUB');

SYNONYM_NAME      OWNER
-------------------- ------------------------------
D       HR
D_PUB       PUBLIC

HR@prod> create synonym d_pub for departments;

Synonym created.

HR@prod> select synonym_name,owner from all_synonyms where synonym_name in('D','D_PUB');

SYNONYM_NAME      OWNER
-------------------- ------------------------------
D               HR
D_PUB           HR
D_PUB           PUBLIC

==私有同义词可以和共有同义词可以重名;