3.1有趣的现象:
1:首先用userdb1用户登录数据库,然后创建一个新表xujs_user
create table xujs_user(id number,name varchar2(21));
2:在数据字典ALL_OBJECTS中(sysdb1用户下)查询刚刚新建的两个表的相关信息。
select * from all_objects where object_name=upper('xujs_user') and object_type=upper('table');
   查出的记录条数为1.4:sysdb1用户下创建存储过程如下:
  create or replace procedure xujs is
    v_count number:=0;
  begin
    select count(1) into v_count from all_objects where object_name='XUJS_USER' and object_type='TABLE';
  end;
  /
5:在sysdb1用户下执行这个存储过程,在存储过程中就查询不到XUJS_USER的信息。即:
   select count(1) into v_count from all_objects where object_name='XUJS_USER' and object_type='TABLE';
   中的v_count为0
6:修改存储过程,加上authid current_user,再执行存储过程,就可以查询到XUJS_USER的信息了,即:
   select count(1) into v_count from all_objects where object_name='XUJS_USER' and object_type='TABLE';
   中的v_count为1
问题:1:为什么单独执行select * from all_objects 的时候可以在字典中查到我刚建的表的相关信息,而在过程中就查不到
      2:为什么加了authid current_user as 就可以在字典中查询到表的信息呢?

解决方案 »

  1.   

    http://space.itpub.net/23445793/viewspace-630952
      

  2.   

    咦?不太清楚。
    我和你的操作过程是一样的,但是我没加authid current_user就可以在sysdb1执行存储过程,并得到1的返回值。
      

  3.   

    存储过程支持所有用户,authid current_user as应该是在存储过程中指出是以当前执行过程的用户来执行
      

  4.   

    select × from tb能得到  但是在存储过程中得不到数据,这个和你拥有的权限有关,在存储过程中调用必须要显式grant select on user才能访问!oracle 直接权限和间接权限!