六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 126|回复: 0

Oracle SQL培训笔记[开发人员][三]

[复制链接]

升级  50%

5

主题

5

主题

5

主题

童生

Rank: 1

积分
25
 楼主| 发表于 2013-1-27 04:35:26 | 显示全部楼层 |阅读模式
四 索引与分页--怎么样SQL运行的更快
<ol>    正确的使用索引
    Where条件落在索引上
    不要在where的=前使用函数,否则无法使用索引
    Is Null可能无法使用索引
    不正确的隐式转换可能不能使用索引
    如果能在索引获得数据,就不要回表
    如果是复合索引,注意第2个字段以后,可能使用不到索引    正确的使用hint
    如果有别名,一定要有别名
    格式如/*+ index(t index_name) */    无需回表查询的分页写法
    存在以下表T1(A,B,C,D) T1上有索引字段(B,C) .如果只是查B,C两个字段则:    <div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee;">select *
      
from (select tt.b, tt.c, rownum as rn
              
from (select t.b, t.c from t1 t where c = 2 order by t.c) tt
             
where rownum < 3)
     
where rn > 1
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表