When will data in Oracle session temporary table get deleted?

两盒软妹~` 提交于 2019-12-10 06:44:52

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/8240810/when-will-data-in-oracle-session-temporary-table-get-deleted

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!