create table tb_test(
t_id number,
t_name nvarchar2(30)
);
create sequence seq_tid
start with 1
increment by 1
maxvalue 999999
minvalue 1
cache 10
--项该表中插入99999条记录
begin
for n in 1..99999 loop
insert into tb_test values(seq_tid.nextval,'1234');
end loop;
end;
--select count(*) from tb_test;
--select * from tb_test;
--select * from tb_test where t_id = 99999;
--此处以下为测试代码,分别在创建索引和没有创建索引的情况下运行
--你会发现创建索引后后运行的时间比没有创建索引所需要的时间少很多
declare
num number;
begin
for n in 1..9999 loop
select t_id into num from tb_test where t_id=n;
end loop;
dbms_output.put_line('nunm='||num);
end;
--创建对应的索引 suncs_space 为自己创建的一个表空间
create index testid on tb_test(t_id) tablespace suncs_space;
--删除索引
drop index testid;
t_id number,
t_name nvarchar2(30)
);
create sequence seq_tid
start with 1
increment by 1
maxvalue 999999
minvalue 1
cache 10
--项该表中插入99999条记录
begin
for n in 1..99999 loop
insert into tb_test values(seq_tid.nextval,'1234');
end loop;
end;
--select count(*) from tb_test;
--select * from tb_test;
--select * from tb_test where t_id = 99999;
--此处以下为测试代码,分别在创建索引和没有创建索引的情况下运行
--你会发现创建索引后后运行的时间比没有创建索引所需要的时间少很多
declare
num number;
begin
for n in 1..9999 loop
select t_id into num from tb_test where t_id=n;
end loop;
dbms_output.put_line('nunm='||num);
end;
--创建对应的索引 suncs_space 为自己创建的一个表空间
create index testid on tb_test(t_id) tablespace suncs_space;
--删除索引
drop index testid;