rem     https://jonathanlewis.wordpress.com/2015/06/17/reverse-key-2/

rem     Script:         c_reverse_ind3.sql
rem     Author:         Jonathan Lewis
rem     Dated:          Jun 2010
rem     Purpose:
rem
 
drop table t1 purge;

create table t1(
        id      not null
)
nologging
as
with generator as (
        select  --+ materialize
                rownum id 
        from dual 
        connect by 
                rownum <= 1e4 -- > comment to avoid wordpress format issue
)
select
        1e7 + rownum    id
from
        generator       v1,
        generator       v2
where
        rownum <= 1e7 -- > comment to avoid WordPress format issue
;
 
begin
        dbms_stats.gather_table_stats(
                ownname          => user,
                tabname          => 'T1'
        );
end;
/
 
alter table t1 add constraint t1_pk primary key(id) 
using index 
        -- reverse 
        nologging 
;

alter system flush shared_pool; 
alter system flush buffer_cache;

alter session set events '10046 trace name context forever, level 8';
 
begin
        for i in 20000001..20010000 loop
                insert into t1 values(i);
        end loop;
end;
/
