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

前端 未结 6 2310
闹比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:04

    Well, I tried it out and the index was visible and used by the second session. Creating a new global temporary table for your data would be safer if you really need an index.

    You are also unable to create an index while any other session is accessing the table.

    Here's the test case I ran:

    --first session
    create global temporary table index_test (val number(15))
    on commit preserve rows;
    
    create unique index idx_val on index_test(val);
    
    --second session
    insert into index_test select rownum from all_tables;
    select * from index_test where val=1;
    

提交回复
热议问题