对于权限控制,有时会通过一个查询(或执行)用户来访问另一个用户的所有对象,常见的是表,有时也需要package body,怎么办?
大致如下:
-
--对于表
-
select 'grant select on '||owner||'.'||table_name||' to user1;' c from dba_tables where owner='USER2';
-
-
--对于视图
-
select 'grant select on '||owner||'.'||view_name||' to user1;' c from dba_views where owner='USER2';
-
-
--对于存储过程、函数等
-
select 'grant execute on '||owner||'.'||object_name||' to user1;' c from dba_objects where owner='USER2' and object_type in ('FUNCTION','PROCEDURE','PACKAGE');
-
-
--对于package body
-
select 'grant debug on '||owner||'.'||object_name||' to user1;' c from dba_objects where owner='USER2' and object_type in ('PACKAGE BODY');
-
将生成的脚本执行即可。
阅读(882) | 评论(0) | 转发(0) |