--创建普通索引
--性能测试 创建一个表,
CREATE TABLE T_INDEXTEST ( ID NUMBER, NAME VARCHAR2(30) );
--向表中插入100万条记录(使用plsql)
begin
for x in 1..1000000
loop
insert into T_INDEXTEST values(x,'AA'||x );
end loop;
commit;
end;
--创建唯一索引
create unique index index_owners_meter on t_owners(watermeter);
select * from t_owners where addressid=1 and housenumber='1-3';
--创建复合索引
create index index_owners_name on t_owners(name);
--性能测试 创建一个表,
CREATE TABLE T_INDEXTEST ( ID NUMBER, NAME VARCHAR2(30) );
--向表中插入100万条记录(使用plsql)
begin
for x in 1..1000000
loop
insert into T_INDEXTEST values(x,'AA'||x );
end loop;
commit;
end;
--创建唯一索引
create unique index index_owners_meter on t_owners(watermeter);
select * from t_owners where addressid=1 and housenumber='1-3';
--创建复合索引
create index index_owners_ah on t_owners(addressid,housenumber);
--反向键 索引
应用场景:当某个字段的值为连续增长,如果构建标准索引会形成歪脖子树,增加查询层数,性能下降,简历反向键索引可通过二进制转换使索引值变得不规则,索引树会均匀分布,提高查询效率。
create index index_owners_name on t_owners(name) reverse;