Is it safe to put an index on an Oracle Temporary Table?

前端 未结 6 2312
闹比i
闹比i 2021-02-19 22:41

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

6条回答
  •  说谎
    说谎 (楼主)
    2021-02-19 23:10

    I assume you're referring to true Oracle temporary tables and not just a regular table created temporarily and then dropped. Yes, it is safe to create indexes on the temp tables and they will be used according to the same rules as a regular tables and indexes.

    [Edit] I see you've refined your question, and here's a somewhat refined answer:

    From:

    Oracle® Database Administrator's Guide
    10g Release 2 (10.2)
    Part Number B14231-02
    

    "Indexes can be created on temporary tables. They are also temporary and the data in the index has the same session or transaction scope as the data in the underlying table."

    If you need the index for efficient processing during the scope of the transaction then I would imagine you'll have to explicitly hint it in the query because the statistics will show no rows for the table.

提交回复
热议问题