授权编辑包/函数/存储过程

Oracle中编译包、函数、存储过程需要有 ALTER ANY PROCEDURE 权限
如果是通过CREATE OR REPLACE PACKAGE 方式编译,则需要添加create ANY PROCEDURE 权限
一般还会需要debug权限

grant create ANY PROCEDURE,ALTER ANY PROCEDURE to test;

--debug
grant debug connect session to test;

--存储过程执行权限
grant execute on apps.testpkg to pi;


如果觉得该权限太大,一般我们还可以通过以下方式赋权

For you to modify a package, the package must be in your own schema or you must have ALTER ANY PROCEDURE system privilege.

create or replace
procedure p1
  is
  begin
      execute immediate 'alter package pkg1 compile';
end;
/

Procedure created.

SQL> grant execute on p1 to u1;

Grant succeeded.

SQL> connect u1/u1
Connected.
SQL> alter package scott.pkg1 compile;
alter package scott.pkg1 compile
*
ERROR at line 1:
ORA-01031: insufficient privileges


SQL> exec scott.p1;

猜你喜欢

转载自blog.csdn.net/Hehuyi_In/article/details/89534880