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