对于权限控制,有时会通过一个查询(或执行)用户来访问另一个用户的所有对象,常见的是表,有时也需要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');
-
将生成的脚本执行即可。
阅读(766) | 评论(0) | 转发(0) |