定义者权限和调用者权限

定义者权限和调用者权限

存储过程定义者权限和调用者权限使用示例默认定义者权限

创建用户

create user xiaomu1 identified by 123456;
create user xiaomu2 identified by 123456;
create role my_xiaomu1;
create role my_xiaomu2;

权限赋值

grant create session to xiaomu1;
grant connect,resource to xiaomu1;
grant create session to my_xiaomu1;
grant my_xiaomu1 to xiaomu1;

grant create session to xiaomu2;
grant connect,resource to xiaomu2;
grant create session to my_xiaomu2;
grant my_xiaomu2 to xiaomu2;

grant create table to xiaomu1;
grant create table to xiaomu2;
grant create PROCEDURE to xiaomu2;
grant unlimited tablespace to xiaomu1;
grant unlimited tablespace to xiaomu2;

创建存储过程和表
xiaomu1

CREATE TABLE department3
(v_deptno NUMBER, 
v_dname  VARCHAR2(20),
v_mgr    NUMBER,
v_loc    NUMBER);

xiaomu2

CREATE TABLE department3
(v_deptno NUMBER, 
v_dname  VARCHAR2(20),
v_mgr    NUMBER,
v_loc    NUMBER);

CREATE OR REPLACE PROCEDURE create_dept10 (
 v_deptno NUMBER,
 v_dname  VARCHAR2,
 v_mgr    NUMBER,
 v_loc    NUMBER) 
AUTHID CURRENT_USER AS
BEGIN
  INSERT INTO department3 VALUES (v_deptno, v_dname, v_mgr, v_loc);
END;
/

sys 给xiaomu1 权限

GRANT SELECT ON xiaomu2.create_dept10  TO xiaomu1;
GRANT EXECUTE ON xiaomu2.create_dept10  TO xiaomu1;

xiaomu1 执行存储过程

CALL xiaomu2.create_dept10(11,'INFO',300,1800);
SELECT *from department3;

在这里插入图片描述

xiaomu2 执行存储过程

CALL xiaomu2.create_dept10(11,'INFO',300,1800);
CALL xiaomu2.create_dept10(11,'INFO',300,1800);
CALL xiaomu2.create_dept10(11,'INFO',300,1800);
SELECT *from department3;

在这里插入图片描述

重新创建定义者权限存储过程
xiaomu2

    CREATE OR REPLACE PROCEDURE create_dept10 (
       v_deptno NUMBER,
       v_dname  VARCHAR2,
       v_mgr    NUMBER,
       v_loc    NUMBER) 
    AS
    BEGIN
       INSERT INTO department3 VALUES (v_deptno, v_dname, v_mgr, v_loc);
    END;
/

xiaomu2 执行存储过程

CALL xiaomu2.create_dept10(11,'INFO',300,1800);
SELECT *from department3;

在这里插入图片描述
xiaomu1 执行存储过程 数据还是1条

CALL xiaomu2.create_dept10(11,'INFO',300,1800);
SELECT *from department3;

在这里插入图片描述
进入xiaomu2 查询数据 多了xiaomu1 插入的一条

SELECT *from department3;

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值