oracle temporary 删除吗,Oracle会话临时表中的数据何时被删除?(When will data in Oracle session temporary table get dele...

Oracle会话临时表中的数据何时被删除?(When will data in Oracle session temporary table get deleted?)

我已经读过,在会话表中,数据在提交过程中仍然存在。 用Ask Tom的话来说。

ON COMMIT PRESERVE ROWS使这成为一个基于会话的临时表。 在注销之前,行将保留在此表中。 只有我可以看到它们,即使我提交后也没有其他会话会看到“我的”行

这里的问题短语是“直到注销”。 以Web应用程序为例,该应用程序与DB保持单一连接。 因此,这意味着登录到Web应用程序的所有用户将共享相同的数据库会话。 那么,这是否意味着所有用户都会在该临时表中看到相同的内容?

在实际的Web应用程序中,我们通常会维护多个DB连接。 这些连接保存在“池”中,并且可以为许多用户重用它们。 在这种情况下,行为可能非常不稳定,用户可能会查看上一个用户填充的数据。

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.

原文:https://stackoverflow.com/questions/8240810

更新时间:2020-01-27 23:25

最满意答案

这也是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.

2011-11-23

相关问答

您的第一种方法应该是将其作为单个查询来执行此操作: SELECT *

FROM

(

SELECT *

FROM tab1 ,

tab2

WHERE tab1.key = tab2.fkey

)

WHERE field1 = 'value';

对于非常复杂的情况或temp#非常大的情况,请尝试使用子查询因子子句,可选择使用materialize提示: with #temp as

(

SELECT /*+ materialize */

*

FRO

...

您的临时表数据仅在事务范围内可见。 提交或回滚事务(或断开连接并重新连接)后,数据将消失。 每次运行查询时都不需要创建表:只需创建一次。 Oracle中的TRUNCATE是一个DDL操作(它提交它运行的事务)。 Your temporary table data is visible only in scope of the transaction. After you commit or rollback the transaction (or disconnect and reconnect)

...

如果您拥有临时表,则在USER_TABLES中列出临时表ALL_TABLES如果您拥有该表,则在ALL_TABLES列出临时表。 如果它存在于数据库中,它将在DBA_TABLES中列出,但您可能没有查询DBA_TABLES权限。 如果表存在于数据库中,但不在ALL_TABLES ,则表示当前用户在临时表上没有权限。 是的,临时表将始终存在(当然,一旦创建它)。 当您指定ON COMMIT DELETE ROWS ,当事务完成(提交或回滚)时,临时表中的数据将被删除。 每个会话将始终只能看到它已经插

...

Hibernate会话与数据库会话不是一对一的对应关系。 因此,要使用临时表而不保证数据库会话将在后续hibernate会话之间续订,应截断它以删除数据。 这是一种低成本的操作。 A Hibernate session is not a one to one correspondence with a database session. So, to use a temporary table with no guarantee that the database session will be

...

DBMS_PIPE是将信息从一个会话推送到另一个会话的“经典”机制。 会话A将不得不将数据推入管道,而会话B将不得不将其拉出。 但通常数据库的理念是会话是独立的,任何共同点都在保存的数据中。 反对这表明你正在使用错误的工具。 DBMS_PIPE is the 'classic' mechanism for pushing information from one session to another. Session A would have to push data into the pipe

...

在Oracle中,你很少需要临时表。 您通常需要在其他数据库中使用临时表,因为这些数据库不会实现多版本读取一致性,并且有可能在您的过程运行时有人从表中读取数据时被阻塞,或者如果过程不会执行脏读操作不会将数据保存到单独的结构中。 由于这些原因之一,Oracle不需要全局临时表,因为读者不会阻止编写器,也不可能使用脏读。 如果您在执行PL / SQL计算时只需要临时地点来存储数据,则PL / SQL集合比Oracle中的临时表更常用。 这样,您就不会将数据从PL / SQL引擎来回推送到SQL引擎并返

...

这也是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. D

...

“按下SAVE按钮后,JTable或临时表中的数据(可能包含多行)应插入实际表中。 请分享您的经验或想法。” 使用DefaultTableModel将信息添加到JTable String[] columnNames = { "Data 1", "Data 2", "Data 3 };

DefaultTableModel model = new DefaultTableModel(columnNames, 0);

JTable table = new JTable(model);

然后,您可以从表

...

我认为这是TemporaryTableBulkIdStrategy中的一个错误,因为当使用Oracle8iDialect时 ,不应删除临时表: @Override

public boolean dropTemporaryTableAfterUse() {

return false;

}

但只有在删除表时才会进行此检查: protected void releaseTempTable(Queryable persister, SessionImplementor session) {

...

虽然你可能想出一些技巧来完成这项工作,至少在某些时候,我建议这几乎肯定会在某些时候引起问题,特别是在从开发服务器转换到生产服务器时。 选项可能包括: 使用永久表,并在逻辑上完成数据后清除数据。 将数据写入平面文件,然后在需要时将其读回。 将数据写入平面文件,然后将该文件作为外部表装入。 分享和享受。 Although you may be able to come up with some trickery to make this work, at least some of the time,

...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值