oracle - 如何知道数据库中某处是否使用了 db-link
问题描述
我想知道是否存在一个 Oracle 命令来了解 DB-LINK(名称:myBDLink)是否在数据库中的某个位置使用以及如何显示对象(视图、物化视图、过程、函数......)用它。
你能帮我吗?
谢谢你的帮助
解决方案
好吧,您可以尝试查询各种系统视图,看看它们中的任何一个是否包含您要查找的字符串。当您想检查整个数据库时,您可能会以特权用户身份连接并检查dba_
视图;否则,all_
或者user_
会这样做。
例如,检查过程、函数、包……:
select owner, name, type, line
from dba_source
where owner not in ('SYS', 'SYSTEM')
and lower(text) like '%mydblink%';
要检查视图,您需要一个函数来搜索其LONG
数据类型列(因为您不能直接在 SQL 中使用它):
create or replace function f_long(par_view in varchar2, par_String in varchar2)
return varchar2
is
l_text varchar2(32000);
begin
select text
into l_text
from dba_views
where owner not in ('SYS', 'SYSTEM')
and view_name = par_view;
return case when instr(lower(l_text), lower(par_string)) > 0 then 1
else 0
end;
end;
/
接着
select owner, view_name
from dba_views
where f_long(view_name, 'mydblink') = 1;
我排除了SYS
,SYSTEM
因为它们不应该包含任何用户的东西。也许您想排除更多用户。
要查看更多(重新)资源,请查询字典,例如
select table_name, comments
from dictionary;
TABLE_NAME COMMENTS
------------------------------ --------------------------------------------------
USER_CONS_COLUMNS Information about accessible columns in constraint
definitions
ALL_CONS_COLUMNS Information about accessible columns in constraint
definitions
DBA_CONS_COLUMNS Information about accessible columns in constraint
definitions
<snip>
推荐阅读
- java - Android Studio调试按钮按下 - 事件未触发
- javascript - 如何在更改选择值时显示/隐藏文本框
- python - 如何更改顺序列并将它们组合在一个熊猫数据框中?
- asp.net - 在 VS 17 中构建 asp.net 项目显示错误“无法加载 System.Threading.Tasks,版本 = 4.0.0.0,”此文件已损坏且无法读取
- django - /password-reset/ 处的 IndexError:重置密码时字符串索引超出范围
- gpu - 有没有办法打破数据加载器循环?
- php - 如何使用 pdo 将 xampp php 7.1.27 连接到 MsSQL 服务器?
- javascript - ngx-translate 提供后备语言
- orbeon - Orbeon 表单动态数据下拉语言 URL 参数
- serilog - 将日志分成多个日志文件