Oracle同义词概念

前端之家收集整理的这篇文章主要介绍了Oracle同义词概念前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Oracle同义词

Oracle的同义词(synonyms)跟View功能类似,但更强大。在Oracle数据库中的大部分数据库对象,如表、视图、物化视图、序列、函数、存储过程、包、同义词等等都可以做为同义词。其目的主要有2个:用于简化对象访问提高对象访问的安全性

下面简单做个演示:

sql> conn scott/tiger

Connected.

sql> create table test1 (id number);

Table created.

sql> insert into test1 values(1);

1 row created.

sql> commit;

1、创建连接用户

sql> conn /as sysdba;

Connected.

sql> create user zsl identified by zsl;

User created.

2、创建profile:

sql> create profile zsl_test1 limitsessions_per_user 5;

Profile created.

3、设置profile绑定用户

sql> alter user zsl profile zsl_test1;

User altered.

4、赋予权限

sql> grant create session to zsl;

Grant succeeded.

sql> grant select on scott.test1 to zsl;

Grant succeeded.

5、创建同义词

sql> create synonym zsl.test1 forscott.test1;

Synonym created.

6、切换到zsl用户下测试

sql> conn zsl/zsl

Connected.

sql> select * from test1;

ID

----------

1

7、查找属主

sql> conn /as sysdba;

Connected.

sql> set line 150

sql> select owner,SYNONYM_NAME,TABLE_OWNER,TABLE_NAME from dba_synonyms where SYNONYM_NAME=upper('test1');

OWNER SYNONYM_NAME TABLE_OWNER TABLE_NAME

---------------- ------------------------- ----------------   -------------------

ZSL   TEST1 SCOTT TEST1

原文链接:https://www.f2er.com/oracle/213669.html

猜你在找的Oracle相关文章