有没有办法找到使用特定包的架构数量。
因此,在更改包之前,我可以知道有多少架构会受到影响。
答案 0 :(得分:1)
这比预期容易:
select * from user_dependencies where name='object_name'
答案 1 :(得分:1)
在stackoverflow上有很多类似的关于对象依赖关系的问题。我找不到完全匹配(其他方案适用于视图或表格类型的对象)。这是一个很好的答案的例子(看看奥利的答案Recursively list concents of Oracle's DBA_DEPENDENCIES view)。
这是我用于此类问题的递归查询:
SELECT LEVEL DEP_LEVEL,
DD.OWNER,
DD.NAME,
DD.REFERENCED_OWNER,
DD.REFERENCED_NAME,
DD.TYPE,
DD.OWNER
|| '.'
|| DD.NAME OBJECT_NAME,
DD.REFERENCED_OWNER
|| '.'
|| DD.REFERENCED_NAME REFERENCED_OBJECT_NAME
FROM DBA_DEPENDENCIES DD
START WITH DD.OWNER = '&package_owner'
AND DD.NAME = '&package_name'
CONNECT BY NOCYCLE PRIOR DD.NAME =DD.REFERENCED_NAME
AND PRIOR DD.OWNER = DD.REFERENCED_OWNER
答案 2 :(得分:0)
您可以使用dba_tab_privs
视图:
SQL> ed
Wrote file afiedt.buf
1 create package test_pkg
2 as
3 function get_one
4 return number;
5* end test_pkg;
SQL> /
SQL> ed
Wrote file afiedt.buf
1 create or replace package body test_pkg
2 as
3 function get_one
4 return number
5 is
6 begin
7 return 1;
8 end get_one;
9* end test_pkg;
SQL> /
SQL> grant execute on test_pkg to hr
2 /
Grant succeeded.
SQL> ed
Wrote file afiedt.buf
1 SELECT grantee
2 FROM dba_tab_privs
3 WHERE table_name = 'TEST_PKG'
4 AND privilege = 'EXECUTE'
5 union
6 SELECT owner
7 FROM dba_tab_privs
8* WHERE table_name = 'TEST_PKG'
SQL> /
GRANTEE
------------------------------
HR
SYS
SQL>