Oracle索引使用详解

-- 索引:普通索引、唯一索引、复合索引

           create index XX on tableNamep[colName]

使用索引的好处,就是检索效率快,和使用主键、rowid(物理地址) 差不多,使用主键检索的实质就是使用ROWID(物理地址)

eg:
     create unique index 索引名 on tablename(列名)
     create index index_test_ah on t_indextest(id,name);
     select * from t_indextest where id = 777580 and name = 'aa7775

-- 索引:普通索引、唯一索引、复合索引
create index XX on tableNamep[colName]
-- 创建一个普通索引
-- 创建索引的好处,就是检索效率快,和使用主键、rowid(物理地址) 差不多,使用主键检索的实质就是使用ROWID(物理地址)
create index index_orders_name on t_owners(name);

create table T_INDEXTEST (ID NUMBER,NAME1 VARCHAR2(30),NAME2 VARCHAR2(30),NAME3 VARCHAR2(30),NAME4 VARCHAR2(30),NAME5 VARCHAR2(30));
begin
  for x in 1..1000000
    loop
      insert into T_INDEXTEST values (x,'aa'||x,'bb'||x,'cc'||x,'dd'||x,'ee'||x);
    end loop;
    commit;
end;

create index index_test on T_INDEXTEST(name);

select * from t_indextest where id = 777580
select * from t_indextest where name = 'aa777580'
select rowid,t.* from t_indextest t where name = 'aa777580'
select * from t_indextest where rowid = 'AAAM3lAAGAAAAmOAFs'

-- 创建唯一索引
create unique index 索引名 on tablename(列名)
create index index_test_ah on t_indextest(id,name);
drop index index_test_ah
select * from t_indextest where id = 777580 and name = 'aa777580'


select * from t_indextest where name1='aa777777' and name2='bb777777' and name3='cc777777'
create index index_indextest_aa on t_indextest(name1,name2,name3)


select * from t_account where year = '2012' and month = '01' and ownerid = 1;

 

  • 0
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值