在Oracle临时表上放置索引是否安全?

问题描述:

我已经读过,不应该分析临时表,因为它会破坏其他人的表统计信息。索引怎么样?如果我在程序的持续时间内在表上放置一个索引,那么使用该表的其他程序是否会受到该索引的影响?

I have read that one should not analyze a temp table, as it screws up the table statistics for others. What about an index? If I put an index on the table for the duration of my program, can other programs using the table be affected by that index?

索引会影响我的吗?进程,以及使用该表的所有其他进程?
或它是否会影响我的流程?

所有回复都没有权威,所以我提供的是贿赂。

None of the responses have been authoritative, so I am offering said bribe.


索引是否会影响我的流程以及使用该表的所有其他流程?或者它是否会影响我的过程?

Does an index effect my process, and all other processes using the table? or Does it effect my process alone?

我假设我们正在讨论 GLOBAL TEMPORARY 表。

I'm assuming we are talking of GLOBAL TEMPORARY tables.

想想一个临时表,就像多个表一样,每个进程都是从存储在存储的模板中创建和删除的。系统词典

Oracle 中, DML 临时表会影响所有进程,而表中包含的数据只会影响使用它们的一个进程。

In Oracle, DML of a temporary table affects all processes, while data contained in the table will affect only one process that uses them.

临时表中的数据仅在会话范围内可见。它使用 TEMPORARY TABLESPACE 来存储数据和可能的索引。

Data in a temporary table is visible only inside the session scope. It uses TEMPORARY TABLESPACE to store both data and possible indexes.

DML 对于临时表(即其布局,包括列名和索引)对于拥有足够权限的每个人都是可见的。

DML for a temporary table (i. e. its layout, including column names and indexes) is visible to everybody with sufficient privileges.

这意味着索引的存在会影响您的进程以及使用该表的其他进程,因为任何修改临时表中的数据的进程都是如此/ code>还必须修改索引。

This means that existence of the index will affect your process as well as other processes using the table in sense that any process that modifies data in the temporary table will also have to modify the index.

数据包含在表格中(以及索引中),相反,它只会影响创建它们的进程,甚至不会被其他进程看到。

Data contained in the table (and in the index too), on the contrary, will affect only the process that created them, and will not even be visible to other processes.

如果你想让一个进程使用索引而另一个进程没有要使用它,请执行以下操作:

IF you want one process to use the index and another one not to use it, do the following:


  • 使用相同列创建两个临时表布局

  • 其中一个的索引

  • 使用索引或非索引的ta取决于过程

  • Create two temporary tables with same column layout
  • Index on one of them
  • Use indexed or non-indexed table depending on the process