Oracle 索引访问方式本篇记录一些Oracle索引访问操作表访问方式请参考:http://www.linuxidc.com/Linux/2013-03/80822.htm显示执行计划的存储过程请参考 http://www.linuxidc.com/Linux/2013-03/80322.htm(1)INDEX UNIQUE SCAN唯一索引扫描,唯一索引即做单一匹配。在唯一索引中,每个非空键值只有唯一的一条,主键也是唯一索引。示例:SQL> exec sql_explain("select * from emp where empno=8888");
Plan hash value: 2949544139
--------------------------------------------------------------------------------
------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time
|
--------------------------------------------------------------------------------
------
| 0 | SELECT STATEMENT | | 1 | 39 | 1 (0)|
00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| EMP | 1 | 39 | 1 (0)|
00:00:01 |
|* 2 | INDEX UNIQUE SCAN | PK_EMP | 1 | | 0 (0)|
00:00:01 |
--------------------------------------------------------------------------------
------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("EMPNO"=8888)PL/SQL 过程已成功完成。(2)INDEX RANGE SCAN非唯一索引扫描,对应唯一索引扫描,索引进行范围匹配,(例如>、<、like等)或进行单一匹配(例如=),示例:SQL> create table t_xyc as select * from emp;表已创建。
SQL> insert into t_xyc select * from emp;已创建15行。SQL> commit;提交完成。
SQL> create index xyc_index on t_xyc(empno);索引已创建。
---用等号(=)进行单一匹配
SQL> exec sql_explain("select * from t_xyc where empno=8888");
Plan hash value: 767710755
-----------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 2 | 78 | 4 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| T_XYC | 2 | 78 | 4 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | XYC_INDEX | 2 | | 1 (0)| 00:00:01 |
-----------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("EMPNO"=8888)PL/SQL 过程已成功完成。
----用大于(>)进行范围匹配
SQL> exec sql_explain("select * from t_xyc where empno>8888");
Plan hash value: 767710755
-----------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 2 | 78 | 4 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| T_XYC | 2 | 78 | 4 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | XYC_INDEX | 2 | | 1 (0)| 00:00:01 |
-----------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("EMPNO">8888)PL/SQL 过程已成功完成。
Oracle 表访问方式Oracle分组函数rollup,cube相关资讯 Oracle索引 Oracle索引访问
- Oracle跳跃式索引扫描测试 (08月09日)
- Oracle组合索引与回表 (08/07/2015 18:11:53)
- Oracle 索引基本原理 (04/12/2015 18:03:58)
| - 关于Oracle位图索引内部浅论 (09/17/2015 19:23:59)
- Oracle 索引的可见与隐藏(visible (07/18/2015 09:41:42)
- Oracle索引合并coalesce操作 (04/01/2015 20:21:34)
|
本文评论 查看全部评论 (0)