有没有办法查看另一个 Oracle 会话的内部情况?

发布于 2024-07-19 08:22:29 字数 541 浏览 9 评论 0原文

我有一个查询编辑器(Toad)查看数据库。

同时,我也在调试一个具有自己单独连接的应用程序。

我的应用程序启动一个事务,进行一些更新,然后根据一些 SELECT 语句做出决策。 由于更新语句(很多且复杂)尚未提交,因此我的应用程序从其 SELECT 获得的结果与在 Toad 中运行相同语句时获得的结果不同。

目前,我通过将应用程序的查询输出转储到文本文件中并读取该文件来解决此问题。

在提交完成之前,是否有更好的方法来查看另一个 Oracle 会话,并查看该会话看到的内容?

另一种提问方式是:在 Oracle 下,我可以启用 脏读仅在两个会话之间,而不影响其他人的会话?

I have a query editor (Toad) looking at the database.

At the same time, I am also debugging an application with its own separate connection.

My application starts a transaction, does some updates, and then makes decisions based on some SELECT statements. Because the update statements (which are many and complex) are not committed yet, the results my application gets from its SELECT are not the same as what I get if I run the same statement in Toad.

Currently I get around this by dumping the query output from the app into a text file, and reading that.

Is there a better way to peek inside another oracle session, and see what that session sees, before the commit is complete?

Another way to ask this is: Under Oracle, can I enable dirty reads between only two sessions, without affecting anyone else's session?

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

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

发布评论

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

评论(3

野味少女 2024-07-26 08:22:29

不可以,Oracle 不允许脏读。 此外,由于更改可能尚未物理写入磁盘,因此您不会在数据文件中找到它们。
日志编写器将至少每三秒写入任何待处理的数据更改,因此您可以使用 Log Miner 工具从那里将其挑选出来。

但一般来说,最好的选择是包含您自己的调试信息,您可以根据需要轻松打开和关闭这些信息。

No, Oracle does not permit dirty reads. Also, since the changes may not have physically been written to disk, you won't find them in the data files.
The log writer will write any pending data changes at least every three seconds, so you may be able to use the Log Miner stuff to pick it out from there.

But in general, your best bet is to include your own debugging information which you can easily switch on and off as required.

寂寞笑我太脆弱 2024-07-26 08:22:29

我知道这不是一个完整的答案,但是虽然没有死读,但有一些锁可以让您了解发生了什么。

在会话 1 中,如果您插入主键为 7 的行,那么当您从会话 2 中进行选择时,您将看不到它。(这将是脏读)。

但是,如果您尝试使用主键 7 从会话 2 进行插入,那么它将在会话 1 之后阻塞,因为它必须等待并查看会话 1 是否会提交或回滚。 您可以使用“WAIT 10”等待 10 秒钟以实现此操作。

对于更新或任何会导致唯一约束违规的事情也存在类似的情况。

It's not a full answer I know, but while there are no dead reads, there are locks that can give you some idea what is going on.

In session 1 if you insert a row with primary key 7, then you will not see it when you select from session 2. (That would be a dirty read).

However, if you attempt an insert from session 2 using the primary key of 7 then it will block behind session 1 as it has to wait and see if session 1 will commit or rollback. You can use "WAIT 10" to wait 10 seconds for this to happen.

A similar story exists for updates or anything that would cause a unique constraint violation.

不打扰别人 2024-07-26 08:22:29

您能否暂时使用更改会话命令或登录触发器(我自己没有尝试过)将想要达到峰值的会话中的隔离级别设置为“读取未提交”?

我更喜欢做的(一般来说)是将调试语句放置在永久保留的代码中,但在生产中被关闭 - Tom Kyte 的 debug.f 包是一个有用的起点 - http://asktom.oracle.com/tkyte/debugf

Can you not just set the isolation level in the session you want to peak at to 'read uncommitted' with an alter session command or a logon trigger (I have not tried this myself) temporarily?

What I prefer to do (in general) is place debug statements in the code that remain there permanently, but are turned off in production - Tom Kyte's debug.f package is a useful place to start - http://asktom.oracle.com/tkyte/debugf

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