下面是自己写的一个小样,只是说说原理。
真实SQL比这个要复杂些,但是处理方法相同。
1建表
SQL> create table test_case_anti
2 as
3 select sysdate+1/24/60 d1, sysdate-356+1/24/60 d2, 1 d3
4 from dual
5 where 1=2 ;
Table created.
2 插入一百万行数据
SQL> begin
2 for i in 1..1000000
3 loop
4 insert into test_case_anti
select sysdate+i/24/60 ,sysdate-356+i/24/60,i from dual ;
5 6 if mod(i,1000)=0 then commit ;end if ;
7
8 end loop ;
9
10 end ;
11 /
PL/SQL procedure successfully completed.
SQL> commit ;
Commit complete.
3 加索引
SQL> create index idx_dao_1 on TEST_CASE_ANTI(d1) ;
Index created.
SQL> create index idx_dao_2 on TEST_CASE_ANTI(d2) ;
Index created.