oracle同义词表不存在,Oracle同义词的使用

今天看书,突然想到了同义词,于是就产生了2个问题:

1、如何查看同义词是public还是private;

2、对public和private同义词是否可以重名?

于是针对这两个问题做了个实验:

首先对scott赋予创建同义词的权限:

sys@ORCL> grant create synonym to scott; (创建私有同义词权限)

sys@ORCL> grant create public synonym to scott;(创建公共同义词的权限)

连接数据库:

sys@ORCL> conn scott/tiger;

Connected.

创建表:

scott@ORCL> create table t(id number);

Table created.

接着创建同义词:

scott@ORCL> create or replace synonym tt for t ; --private synonym

Synonym created.

scott@ORCL> create or replace public synonym tt for t; --public synonym

Synonym created.

然后以sys用户查看dba_synonyms

scott@ORCL> conn / as sysdba

Connected.

sys@ORCL> col owner for a10;

sys@ORCL> col synonym_name for a

你可能感兴趣的:(oracle同义词表不存在)