Oracle 創建同義詞


1:以sysdba登陸系統,首先創建一個用戶

SQL> conn /as sysdba
Connected.
SQL> create user yshy identified by yshy;

User created.

SQL> grant connect to yshy;

Grant succeeded.

SQL> grant resource to yshy;

Grant succeeded.

SQL> grant create synonym to yshy;

Grant succeeded.

SQL> 

2:切換到yshy用戶,並創建同義詞針對scott.emp

SQL> conn yshy/yshy
Connected.

SQL> create synonym y_emp for scott.emp;

Synonym created.

3:查詢同義詞,提示表或視圖不存在。

SQL> select * from y_emp;
select * from y_emp
              *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> 

4:登陸scott把emp表的查詢權限授權給yshy用戶。

SQL> conn scott/tiger
Connected.
SQL> grant select on emp to yshy;

Grant succeeded.

SQL> conn yshy/yshy;
Connected.
SQL> select * from y_emp;

【刪除同義詞】
DROP [PUBLIC] SYNONYM [schema.]sysnonym_name

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM