Oracle的同義詞(synonyms)跟View功能類似,但更強(qiáng)大。在Oracle數(shù)據(jù)庫中的大部分?jǐn)?shù)據(jù)庫對(duì)象,如表、視圖、物化視圖、序列、函數(shù)、存儲(chǔ)過程、包、同義詞等等都可以做為同義詞。其目的主要有2個(gè):用于簡化對(duì)象訪問和提高對(duì)象訪問的安全性。
站在用戶的角度思考問題,與客戶深入溝通,找到蛟河網(wǎng)站設(shè)計(jì)與蛟河網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類型包括:成都網(wǎng)站建設(shè)、網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、主機(jī)域名、網(wǎng)站空間、企業(yè)郵箱。業(yè)務(wù)覆蓋蛟河地區(qū)。
下面簡單做個(gè)演示:
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、創(chuàng)建連接用戶:
SQL> conn /as sysdba;
Connected.
SQL> create user zsl identified by zsl;
User created.
2、創(chuàng)建profile:
SQL> create profile zsl_test1 limitsessions_per_user 5;
Profile created.
3、設(shè)置profile綁定用戶:
SQL> alter user zsl profile zsl_test1;
User altered.
4、賦予權(quán)限
SQL> grant create session to zsl;
Grant succeeded.
SQL> grant select on scott.test1 to zsl;
Grant succeeded.
5、創(chuàng)建同義詞
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