SCOTT@ora11g>create procedure p_test as
2 begin
3 execute immediate 'create table t_yhc as select * from emp';
4 end;
5 /
Procedure created.
2 begin
3 execute immediate 'create table t_yhc as select * from emp';
4 end;
5 /
Procedure created.
SCOTT@ora11g>exec p_test;
BEGIN p_test; END;
*
ERROR at line 1:
ORA-01031: insufficient privileges
ORA-06512: at "SCOTT.P_TEST", line 3
ORA-06512: at line 1
BEGIN p_test; END;
*
ERROR at line 1:
ORA-01031: insufficient privileges
ORA-06512: at "SCOTT.P_TEST", line 3
ORA-06512: at line 1
说明:在物化视图和存储过程都有个隐式授权的问题。
相关权限需直接GRANT,不能通过ROLE
SCOTT@ora11g>conn / as sysdba
SYS@ora11g>grant create table to scott;
SYS@ora11g>conn scott/tiger
Connected.
SCOTT@ora11g>exec p_test;
SYS@ora11g>grant create table to scott;
SYS@ora11g>conn scott/tiger
Connected.
SCOTT@ora11g>exec p_test;
PL/SQL procedure successfully completed.