201934 oracle存储过程访问其它用户表权限不足

奇怪,这是自己第一次遇到这种情况

同事告诉我,他在usrB下直接查询 select * from usrA.table_1; 是可以查到数据的
但是,把类似这种话放到存储过程中,执行,就提示表或视图不存在。
奇怪了

我实践了一下,也发现这个问题。
需要指出的是,select col1 from usrA.table_1; 这种语法在存储过程中是会提示错误的:在此select 语句中缺少into子句

存储过程修改为:

create or replace procedure p1 is
var1 varchar2(200);
verrmsg varchar2(1000); --错误提示
begin
 select 1 into var1 from dual;
 exception
 when no_data_found then
 verrmsg := 'no data found!';
 end p1;

编译通过。
可是,把里面的select 语句,换成 usrA.table_1 相关的,就又开始提示:表或视图不存在。
见鬼了。
后来,在文章:
https://blog.csdn.net/liangyike/article/details/7534299

http://www.itpub.net/thread-1580652-1-1.html
知道,在
usrA用户下执行:

grant select on table_1 to usrB with grant option;

然后,到usrB下重新编译存储过程,就通过了。

陆科说,这是因为授权的传递问题。
可是我还是没能明白。
等过一阵子再来思考吧。

发布了83 篇原创文章 · 获赞 18 · 访问量 9万+

猜你喜欢

转载自blog.csdn.net/Partner2016/article/details/93100934