Oracle会话临时表中的数据什么时候会被删除?
我读到,在会话表中,数据在提交过程中仍然存在。用问汤姆的话来说。
ON COMMIT PRESERVE ROWS 使其成为基于临时会话 桌子。行将保留在此表中,直到注销。只有我能看到 但是,即使在我之后,其他会话也不会看到“我的”行 提交
我这里的问题短语是“直到注销”。以维护与数据库的单个连接的 Web 应用程序为例。因此,这意味着登录到 Web 应用程序的所有用户都将共享相同的数据库会话。那么,这是否意味着所有用户都会在该临时表中看到相同的内容?
在实际的 Web 应用程序中,我们通常维护多个数据库连接。这些连接维护在“池”中,并且可供许多用户重复使用。在这种情况下,行为可能会非常不稳定,并且用户可能会查看上一个用户填充的数据。
I have read that in session tables the data survives the commit process. In words of Ask Tom.
the ON COMMIT PRESERVE ROWS makes this a session based temporary
table. rows will stay in this table until a logoff. Only I can see
them though, no other session will ever see 'my' rows even after I
commit
The problem phrase for me here is "until a logoff". Take the case of a web application which maintains a single connection to DB. So this means that all users logged into the web application are going to share the same DB session. So, does this mean that all users are going to see the same content in that temporary table?
In a practical web application typically we maintain multiple DB connections. These connections are maintained in a "pool" and they are reused for many users. In this scenario then the behavior could be quite erratic and the user may view data populated by last user.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这就是 Oracle 还提供“ON COMMIT DELETE ROWS”选项的原因。
全局临时表中的数据可以具有会话范围(即ON COMMIT PRESERVE ROWS)或事务范围(ON COMMIT DELETE ROWS)。
显然,在连接池和共享服务器/共享会话的情况下,您将需要事务范围(ON COMMIT DELETE ROWS)。
希望有帮助。
Which is why Oracle provides an 'ON COMMIT DELETE ROWS' option as well.
Data in global temporary tables can have session scope (i.e. ON COMMIT PRESERVE ROWS) or transaction scope (ON COMMIT DELETE ROWS).
Clearly, in the case of connection pooling and shared servers/shared sessions, you'll want transaction scope (ON COMMIT DELETE ROWS).
Hope that helps.