上海网站建设建议,品牌打造的思路与方法,沈阳响应式网站制作,网站搜索出来有图片最后更新时间: 2014年4月13日,星期日存储过程分为两种#xff0c;即DR(Definers Rights ) Procedure和IR(Invokers Rights ) Procedure。为什么会有两种存储过程呢#xff1f;比如说用户user02创建了修改表t1的存储过程#xff0c;当用户user01调用时,是修改的user01自己的t… 最后更新时间: 2014年4月13日,星期日存储过程分为两种即DR(Definers Rights ) Procedure和IR(Invokers Rights ) Procedure。为什么会有两种存储过程呢比如说用户user02创建了修改表t1的存储过程当用户user01调用时,是修改的user01自己的t1表还是user02的t1表? 示例:用户user02将存过赋执行权限给user01:grant execute on user02.prc1 to user01;grant execute on user02.prc2 to user01;grant execute on user02.prc3 to user01;用户user01执行user02下的存过 prc1,prc2,prc3;用户user01只有执行user02下存过的权限,没有查询/修改user02.t1的任何权限;--默认是 authid DEFINERcreate or replace procedure prc1 isv_sql varchar2(200);begin begin v_sql :drop table t1 purge;EXECUTE IMMEDIATE v_sql;v_sql:create table t1(id int);EXECUTE IMMEDIATE v_sql; exception when others thendbms_output.put_line(表不存在!);v_sql:create table t1(id int);EXECUTE IMMEDIATE v_sql; end; for i in 1 .. 10 loop insert into t1 values(0); end loop; commit;end;/-- DEFINER 表示使用的是定义者的权限,即user02的权限,修改的是 user02.t1表,尽管user01没有直接修改user02.t1表的任何权限create or replace procedure prc2 authid DEFINER isv_sql varchar2(200);begin begin v_sql :drop table t1 purge;EXECUTE IMMEDIATE v_sql;v_sql:create table t1(id int);EXECUTE IMMEDIATE v_sql;exception when others thendbms_output.put_line(表不存在!);v_sql:create table t1(id int);EXECUTE IMMEDIATE v_sql;end;for i in 1 .. 10loopinsert into t1 values(2);end loop;commit;end;/-- current_user 表示调用者权限,修改的是user01.t1表create or replace procedure prc3 authid current_user isv_sql varchar2(200);begin begin v_sql :drop table t1 purge;EXECUTE IMMEDIATE v_sql;v_sql:create table t1(id int);EXECUTE IMMEDIATE v_sql;exception when others thendbms_output.put_line(表不存在!);v_sql:create table t1(id int);EXECUTE IMMEDIATE v_sql;end;for i in 1 .. 10loopinsert into t1 values(3);end loop;commit;end;/参考: http://blog.itpub.net/12272958/viewspace-686460/ http://docs.oracle.com/cd/B12037_01/appdev.101/b10807/08_subs.htm#i18574 1. 匿名块(DECLARE BEGIN END;)总是IR Procedure触发器和视图总是DR Procedure。我们可以通过视图*_PROCEDURES来查看存储过程的AUTHID属性值。2. 存储过程、包、都适用。来自为知笔记(Wiz)转载于:https://www.cnblogs.com/bowshy/p/3661867.html