|
 |
|
ss
Oracle Tips by Burleson |
Using CTAS with an Index
Hint
The CTAS with an index hint executes quite differently than CTAS
with order by. When using an index hint, the CTAS begins by
retrieving the table rows from the original table using the existing
index. Since the rows are initially retrieved in the proper order,
there is no need to sort the result set, and the data is used
immediately to create the new table.
The syntax for CTAS with an index hint
appears below:
create table new_customer
tablespace customer_flip
storage (initial 500m
next 50m
maxextents unlimited)
as select /*+ index(customer customer_primary_key_idx) */ *
from customer;
When this statement executes, the database traverses the existing
primary-key index to access the rows for the new table, bypassing
the sorting operation. Most Oracle DBAs choose this method over the
order by approach because the runtime performance of traversing an
index is generally faster than using the PARALLEL clause and then
sorting the entire result set.
Download your Oracle scripts now:
www.oracle-script.com
The
definitive Oracle Script collection for every Oracle professional DBA
|
|