码迷,mamicode.com
首页 > 数据库 > 详细

Oracle 创建同义词

时间:2014-11-11 09:18:28      阅读:118      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   sp   for   div   on   log   bs   

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

 

Oracle 创建同义词

标签:style   blog   color   sp   for   div   on   log   bs   

原文地址:http://www.cnblogs.com/yshyee/p/4088652.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!