如果用户
A
创建了一个视图并将其上的READ
授予PUBLIC
。
SQL>create view A.a_public as select 3 id from dual;
View created.
SQL>select * from A.a_public;
ID
----------
3
SQL>grant read on A.a_public to public;
Grant succeeded.
然后用户
B
可以从 A
的视图中选择创建一个存储过程并成功执行该存储过程。
SQL>create or replace procedure B.b_public
2 as
3 num NUMBER;
4 begin
5 select id into num from A.a_public;
6 dbms_output.put_line('~' || num || '~');
7 end;
8 /
Procedure created.
SQL>show errors
No errors.
SQL>set serveroutput on
SQL>exec B.b_public();
~3~
PL/SQL procedure successfully completed.
SQL>
READ
的 SYS.V_$RESTORE_POINT
已授予 PUBLIC
。
下面的存储过程,为什么编译成功,但执行失败?
SQL>select count(*) from dba_tab_privs where table_name = 'V_$RESTORE_POINT' and grantor = 'SYS' and grantee = 'PUBLIC' and privilege = 'READ';
COUNT(*)
----------
1
SQL>create or replace procedure w_restore_point
2 as
3 num_scn NUMBER;
4 begin
5 select scn into num_scn from
6 SYS.v_$restore_point
7 where rownum = 1;
8 dbms_output.put_line(num_scn);
9 end;
10 /
Procedure created.
SQL>show errors
No errors.
SQL>set serveroutput on
SQL>exec w_restore_point();
BEGIN w_restore_point(); END;
*
ERROR at line 1:
ORA-01031: insufficient privileges
ORA-06512: at "SCHEMA_NAME.W_RESTORE_POINT", line 5
ORA-06512: at line 1
SQL>
使用 Oracle 19c EE。
看起来您必须向正在使用
select_catalog_role
的 procedure 授予 v_$restore_point
权限。
grant select_catalog_role to procedure B.b_public;