执行包以及查看包的定义

---今天在CSDN看到一网友提关于执行包的权限以及查看包的定义 现在把我的操作过程记下来。

 

 

 

scott@ORCL> create or replace package pck_fsum
 
2  as
 
3  function fun_sumsal(c_deptno emp.deptno%type) return number;
 
4  end;
 
5  /

程序包已创建。

scott
@ORCL> ed
已写入
file afiedt.buf

 
1  create or replace package body pck_fsum
 
2  as
 
3  function fun_sumsal(c_deptno emp.deptno%type) return number
 
4  as
 
5  c_sal number;
 
6  begin
 
7  select sum(sal) into c_sal from emp where deptno=c_deptno;
 
8  return c_sal;
 
9  end;
10* end;
scott
@ORCL> /

程序包体已创建。




 
1* create user test1 identified by sys
scott
@ORCL> /

用户已创建。

scott
@ORCL> grant connect,resource to test1
 
2  /

授权成功。
scott
@ORCL> ed
已写入
file afiedt.buf

 
1* grant execute on pck_fsum to test1
scott
@ORCL> /

授权成功。

scott
@ORCL> conn test1/sys
已连接。
test1
@ORCL> ed
已写入
file afiedt.buf

 
1* select scott.pck_fsum.fun_sumsal(10) from dual
test1
@ORCL> /

SCOTT.PCK_FSUM.FUN_SUMSAL(
10)
-----------------------------
                         8750


----查看包头包体的定义

test1
@ORCL> conn scott/sys
已连接。
scott
@ORCL> grant select  on all_source to test1
 
2  /

授权成功。

scott
@ORCL> grant debug on pck_fsum to test1   ---关键这里
  2  /

授权成功。

scott
@ORCL> set long 1000
scott
@ORCL> conn test1/sys
已连接。

test1
@ORCL> set pagesize 200
test1
@ORCL> select text from all_source a where a.type in('PACKAGE','PACKAGE BODY')
 
2  and  a.name=upper('pck_fsum')
 
3  /

TEXT
--------------------------------------------------------------------------------
package pck_fsum
as
function fun_sumsal(c_deptno emp.deptno%type) return number;
end;
package body pck_fsum
as
function fun_sumsal(c_deptno emp.deptno%type) return number
as
c_sal
number;
begin
select sum(sal) into c_sal from emp where deptno=c_deptno;
return c_sal;
end;
end;

已选择14行。

test1
@ORCL>

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值