如何找出数据库表的填充位置?

发布于 2024-09-01 15:17:43 字数 98 浏览 2 评论 0原文

我负责一个 Oracle 数据库,我们没有任何文档。目前我需要知道如何填充表格。

我如何找出该表从哪个过程、触发器或其他源获取数据?

I'm in charge of an Oracle database for which we don't have any documentation. At the moment I need to know how a table is getting populated.

How can I find out which procedure, trigger, or other source, this table is getting its data from?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

暗恋未遂 2024-09-08 15:17:43

或者更好的是,查询 DBA_DEPENDENCIES 表(或其等效的 USER_ )。您应该了解哪些对象依赖于它们以及谁拥有它们。

select owner, name, type, referenced_owner
from dba_dependencies
where referenced_name = 'YOUR_TABLE'

是的,您需要查看对象以查看是否发生插入。

另外,来自我上面的评论。

如果不是生产系统,我建议你提高一个用户
在 INSERT 之前在 TRIGGER- 中定义异常并带有一些自定义消息
或从 INSERT 锁定表并监视执行该操作的应用程序
尝试插入它们失败。但是,是的,您也可能会接到电话
来自许多愤怒的人。

Or even better, query the DBA_DEPENDENCIES table (or its equivalent USER_ ). You should see what objects are dependent on them and who owns them.

select owner, name, type, referenced_owner
from dba_dependencies
where referenced_name = 'YOUR_TABLE'

And yeah, you need to see through the objects to see whether there is an INSERT happening in.

Also this, from my comment above.

If it is not a production system, I would suggest you to raise an user
defined exception in TRIGGER- before INSERT with some custom message
or LOCK the table from INSERT and watch over the applications which
try inserting into them failing. But yeah, you might also get calls
from many angry people.

感悟人生的甜 2024-09-08 15:17:43

这非常简单;-)

SELECT * FROM USER_SOURCE WHERE UPPER(TEXT) LIKE '%NAME_OF_YOUR_TABLE%';

在输出中,您将拥有所有过程、函数等,它们在其主体中调用名为 NAME_OF_YOUR_TABLE 的表。

NAME_OF_YOUR_TABLE 必须大写,因为我们使用 UPPER(TEXT) 来检索 Name_Of_Your_Table、NAME_of_YOUR_table、NaMe_Of_YoUr_TaBlE 等结果。

It is quite simple ;-)

SELECT * FROM USER_SOURCE WHERE UPPER(TEXT) LIKE '%NAME_OF_YOUR_TABLE%';

In output you'll have all procedures, functions, and so on, that in ther body invoke your table called NAME_OF_YOUR_TABLE.

NAME_OF_YOUR_TABLE has to be written UPPERCASE because we are using UPPER(TEXT) in order to retrieve results as Name_Of_Your_Table, NAME_of_YOUR_table, NaMe_Of_YoUr_TaBlE, and so on.

九公里浅绿 2024-09-08 15:17:43

另一个想法是尝试查询 v$sql 以查找执行更新的语句。您可能会从模块/操作(或在 10g progam_id 和 program_line# 中)得到一些东西。

Another thought is to try querying v$sql to find a statement that performs the update. You may get something from the module/action (or in 10g progam_id and program_line#).

难得心□动 2024-09-08 15:17:43

DML 更改记录在 *_TAB_MODIFICATIONS 中。

无需创建触发器,您就可以使用 LOG MINER 来查找所有数据更改以及来自哪个会话。

使用触发器,您可以将 SYS_CONTEXT 变量记录到表中。

http://download.oracle.com/文档/cd/B19306_01/server.102/b14200/functions165.htm#SQLRF06117

DML changes are recorded in *_TAB_MODIFICATIONS.

Without creating triggers you can use LOG MINER to find all data changes and from which session.

With a trigger you can record SYS_CONTEXT variables into a table.

http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions165.htm#SQLRF06117

酷遇一生 2024-09-08 15:17:43

听起来你想审核。

或者

AUDIT ALL ON ::TABLE::;

在表上应用 DBMS_FGA 策略并收集客户端、程序、用户,也许调用堆栈也可用。

Sounds like you want to audit.

How about

AUDIT ALL ON ::TABLE::;

Alternatively apply DBMS_FGA policy on the table and collect the client, program, user, and maybe the call stack would be available too.

时光无声 2024-09-08 15:17:43

聚会迟到了!

我也赞同 Gary 提到的 v$sql。只要查询尚未被刷新,就可以快速得到答案。

如果您知道当前实例中的情况,我喜欢上面使用的组合;如果没有动态SQL,xxx_Dependency将工作并且工作得很好。

将其加入 xxx_Source 以获得讨厌的动态 SQL。

我们还使用 SQL*Plus 复制命令将数据引入我们的开发实例(小心!已弃用!),但数据也可以通过 imp 或 impdp 引入。检查 xxx_Directories 中是否有能够导入/导出数据的目录。

Late to the party!

I second Gary's mention of v$sql also. That may yield the quick answer as long as the query hasn't been flushed.

If you know its in your current instance, I like a combination of what has been used above; if there is no dynamic SQL, xxx_Dependencies will work and work well.

Join that to xxx_Source to get that pesky dynamic SQL.

We are also bringing data into our dev instance using the SQL*Plus copy command (careful! deprecated!), but data can be introduced by imp or impdp as well. Check xxx_Directories for the directories blessed to bring data in/out.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文