存储过程的权限

WUNKANG 2010-12-22 08:33:25
存储过程可以授那些权限啊?
GRANT EXECUTE ON PROCEDURE_NAME TO USER_B;

我想授给USER_B用户执行权限和查看这个存储过程的权限,但不能编辑修改这个存储过程,
有知道的告诉我啊,谢谢了~
...全文
1139 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
tangren 2010-12-25
  • 打赏
  • 举报
回复
tangren 2010-12-25
  • 打赏
  • 举报
回复
晕~~~~
tangren 2010-12-25
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 wunkang 的回复:]

第一个不是我要的效果,
第二个看不懂也执行不了,

引用 12 楼 tangren 的回复:
引用 11 楼 hyl04 的回复:

引用 9 楼 tangren 的回复:
1、如果只想授予一个用户对一个包的执行权限,但不能查看包体:
grant execute on package_name to user_name;
2、如果想授予一个用户所有包的执行权限,并且能查看包体,……
[/Quote]

user_name 要换成自己的用户名,楼主咱就不会思考,只能完全照搬??
心中的彩虹 2010-12-25
  • 打赏
  • 举报
回复




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>








Leshami 2010-12-25
  • 打赏
  • 举报
回复
楼主对有关权限的问题不太清楚,
详细请参考这里:
Oracle 用户、对象权限、系统权限
Oracle 角色、配置文件
WUNKANG 2010-12-25
  • 打赏
  • 举报
回复
第一个不是我要的效果,
第二个看不懂也执行不了,

[Quote=引用 12 楼 tangren 的回复:]
引用 11 楼 hyl04 的回复:

引用 9 楼 tangren 的回复:
1、如果只想授予一个用户对一个包的执行权限,但不能查看包体:
grant execute on package_name to user_name;
2、如果想授予一个用户所有包的执行权限,并且能查看包体,但不能修改编译:
grant create any procedure,select any tabl……
[/Quote]
tangren 2010-12-25
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 hyl04 的回复:]

引用 9 楼 tangren 的回复:
1、如果只想授予一个用户对一个包的执行权限,但不能查看包体:
grant execute on package_name to user_name;
2、如果想授予一个用户所有包的执行权限,并且能查看包体,但不能修改编译:
grant create any procedure,select any table,execute any procedu……
[/Quote]
你不会是原样不动拿去执行吗?package_name要换成自己的包名。
hyl04 2010-12-24
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 tangren 的回复:]
1、如果只想授予一个用户对一个包的执行权限,但不能查看包体:
grant execute on package_name to user_name;
2、如果想授予一个用户所有包的执行权限,并且能查看包体,但不能修改编译:
grant create any procedure,select any table,execute any procedure to user_name;
[/Quote]
第一个执行之后报"ORA-04042:过程, 函数, 程序包或程序包体不存在"错误,好像不对哎
hyf_0023 2010-12-23
  • 打赏
  • 举报
回复
Wrap加密一下!
hyl04 2010-12-23
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 wunkang 的回复:]
补充一下,是PACKAGE里的Body部分,而不是单个的PROCEDURE
[/Quote]
这样好像不行吧!关注中!
xman_78tom 2010-12-23
  • 打赏
  • 举报
回复
grant execute on pkgname to usrname;

grant select_catalog_role to usrname;
tangren 2010-12-23
  • 打赏
  • 举报
回复
1、如果只想授予一个用户对一个包的执行权限,但不能查看包体:
grant execute on package_name to user_name;
2、如果想授予一个用户所有包的执行权限,并且能查看包体,但不能修改编译:
grant create any procedure,select any table,execute any procedure to user_name;
WUNKANG 2010-12-22
  • 打赏
  • 举报
回复
给这个权限不能看到Body里的内容啊,

[Quote=引用 2 楼 java3344520 的回复:]
我想授给USER_B用户执行权限和查看这个存储过程的权限

j就EXECUTE 权限就可以了
[/Quote]
WUNKANG 2010-12-22
  • 打赏
  • 举报
回复
可能我没有表达清楚/
我是在USER_A用户里创建里存储过程,想将这个存储过程的执行和查看权限授权给USER_B用户,


[Quote=引用 1 楼 oraclefans_ 的回复:]
SQL code

SQL> select * from session_privs where PRIVILEGE like '%PROCEDURE%';

PRIVILEGE
----------------------------------……
[/Quote]
iqlife 2010-12-22
  • 打赏
  • 举报
回复
我想授给USER_B用户执行权限和查看这个存储过程的权限

j就EXECUTE 权限就可以了
Oraclefans_ 2010-12-22
  • 打赏
  • 举报
回复

SQL> select * from session_privs where PRIVILEGE like '%PROCEDURE%';

PRIVILEGE
----------------------------------------
CREATE PROCEDURE
CREATE ANY PROCEDURE
ALTER ANY PROCEDURE
DROP ANY PROCEDURE
EXECUTE ANY PROCEDURE
DEBUG ANY PROCEDURE

-------授予CREATE ANY PROCEDURE ,EXECUTE ANY PROCEDURE
WUNKANG 2010-12-22
  • 打赏
  • 举报
回复
补充一下,是PACKAGE里的Body部分,而不是单个的PROCEDURE
心中的彩虹 2010-12-22
  • 打赏
  • 举报
回复
[Quote=引用楼主 wunkang 的回复:]
存储过程可以授那些权限啊?
GRANT EXECUTE ON PROCEDURE_NAME TO USER_B;

我想授给USER_B用户执行权限和查看这个存储过程的权限,但不能编辑修改这个存储过程,
有知道的告诉我啊,谢谢了~
[/Quote]
你的就可以了

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧